Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Testing Fluidity with Chauffeur.TestingTools
using Chauffeur.TestingTools;
using Fluidity.Configuration;
using Fluidity.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Umbraco.Core;
using Xunit;
namespace FluidityTests
{
public class DemoTests : UmbracoHostTestBase
{
private readonly DefaultFluidityRepository fluidityRepo;
public DemoTests()
{
Host.Run(new[] { "install y" }).Wait();
ApplicationContext.Current.DatabaseContext.Database.Execute(@"
CREATE TABLE [Person] (
[Id] int IDENTITY (1,1) NOT NULL,
[Name] nvarchar(255) NOT NULL
);");
fluidityRepo = new DefaultFluidityRepository(
new FluidityCollectionConfig<Person>(
p => p.Id,
"Person",
"People",
"Them people"
)
);
}
[Fact]
public void Can_Create_A_Person()
{
var person = new Person
{
Name = "Aaron Powell"
};
Fluidity.Fluidity.SavingEntity += (sender, args) =>
{
Assert.Null(args.Entity.Before);
Assert.Equal(person.Name, ((Person)args.Entity.After).Name);
};
fluidityRepo.Save(person);
var allPeople = fluidityRepo.GetAll();
Assert.Single(allPeople);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.