Skip to content

Instantly share code, notes, and snippets.

@aaronpowell
Created April 10, 2018 23:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aaronpowell/5d66a91f3bf7b6687e25d05caa67ba82 to your computer and use it in GitHub Desktop.
Save aaronpowell/5d66a91f3bf7b6687e25d05caa67ba82 to your computer and use it in GitHub Desktop.
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