public void GetMeal() { var configurationMock = new Mock<IConfiguration>(); configurationMock.Setup( x => x.DataSource ).Returns( DataSourceType.XMLFile ); configurationMock.Setup( x => x.FileName ).Returns( FullTestData.DataFileName ); FullTestData.Reset(); var dataRepository = new HealthTracker.DataRepository.Services.DataRepository( configurationMock.Object ); // Request a meal that does not exist, should be null var item = dataRepository.GetMeal( Guid.NewGuid() ); Assert.IsNull( item ); // Request a food group that exists, show that a deep copy is returned // Find a food group that does exist, show that a deep copy is returned item = dataRepository.GetMeal( new Guid( "53edb94e-3b15-497e-9907-34de41c9bc8d" ) ); Assert.AreEqual( "Lunch with Bob", item.Name ); Assert.AreEqual( new Guid( "53edb94e-3b15-497e-9907-34de41c9bc8d" ), item.ID ); var sameItem = dataRepository.GetMeal( new Guid( "53edb94e-3b15-497e-9907-34de41c9bc8d" ) ); Assert.AreEqual( item.ID, sameItem.ID ); Assert.AreNotEqual( item, sameItem ); // Show deep copy // Verify that changes to the first found food group do not affect changes to what is logically // the same food group returned by the second find (IOW, show they are deep copies). item.Name = "Whatever, does not matter much"; Assert.AreEqual( "Whatever, does not matter much", item.Name ); Assert.AreEqual( "Lunch with Bob", sameItem.Name ); }