Created
April 10, 2018 23:43
-
-
Save aaronpowell/5d66a91f3bf7b6687e25d05caa67ba82 to your computer and use it in GitHub Desktop.
Testing Fluidity with Chauffeur.TestingTools
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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