public void FetchByPersonId() { // Arrange var generator = new RandomObjectGenerator(); var expected = new E.Person { Id = generator.Generate<int>(), FirstName = generator.Generate<string>(), MiddleName = generator.Generate<string>(), LastName = generator.Generate<string>(), Gender = generator.Generate<string>() }; var dbSet = new InMemoryDbSet<E.Person> { expected }; PersonTests.Arrange(mockedContext => { mockedContext.Setup(_ => _.People).Returns(dbSet); mockedContext.Setup(_ => _.Dispose()); }, (() => { // Act var expectedId = expected.Id; var actual = DataPortal.Fetch<Person>(expectedId); // Assert Assert.IsNotNull(actual); Assert.IsFalse(actual.IsNew, actual.GetPropertyName(_ => _.IsNew)); Assert.AreEqual(expectedId, actual.Id, actual.GetPropertyName(_ => _.Id)); Assert.AreEqual(expected.FirstName, actual.FirstName, actual.GetPropertyName(_ => _.FirstName)); Assert.AreEqual(expected.MiddleName, actual.MiddleName, actual.GetPropertyName(_ => _.MiddleName)); Assert.AreEqual(expected.LastName, actual.LastName, actual.GetPropertyName(_ => _.LastName)); Assert.AreEqual(expected.Gender, actual.Gender, actual.GetPropertyName(_ => _.Gender)); })); }
public void ChildFetchWithOutMiddleName() { // Arrange var generator = new RandomObjectGenerator(); var expected = new E.Person { Id = generator.Generate<int>(), FirstName = generator.Generate<string>(), MiddleName = string.Empty, LastName = generator.Generate<string>(), Gender = generator.Generate<string>() }; var expectedFullname = string.Format("{0} {1}", expected.FirstName, expected.LastName); // Act var actual = AssemblyTests.DoChildOperation(() => DataPortal.FetchChild<PersonView>(expected)); // Assert Assert.IsNotNull(actual); Assert.AreEqual(expected.Id, actual.Id, actual.GetPropertyName(_ => _.Id)); Assert.AreEqual(expectedFullname, actual.FullName, actual.GetPropertyName(_ => _.FullName)); Assert.AreEqual(expected.Gender, actual.Gender, actual.GetPropertyName(_ => _.Gender)); }