public async Task Xml_Data_Saved_In_DataBase_Should_Be_Properly_Restored() { ServiceCollection services = new ServiceCollectionBuilder().PrepareServiceCollection(s => { s.ResetDapperCustomTypeHandlers(); s.RegisterDapperCustomTypeHandlers(Assembly.GetExecutingAssembly()); }); ServiceProvider serviceProvider = services.BuildServiceProvider(); using (IServiceScope scope = serviceProvider.CreateScope()) { var scopedServices = scope.ServiceProvider; ITestObjectRepository testObjectRepository = scopedServices.GetRequiredService <ITestObjectRepository>(); TestXmlObject testObject = CreateFullTestObject(); // Act await testObjectRepository.SaveTestXmlObject(testObject); TestXmlObject retrievedTestObject = await testObjectRepository.GetTestXmlObject(testObject.Id); // Assert retrievedTestObject.Should().NotBeNull(); retrievedTestObject.Should().BeEquivalentTo(testObject); retrievedTestObject.Content.Should().BeEquivalentTo(testObject.Content); } }
public async Task Null_Xml_Data_Saved_In_DataBase_Should_Be_Restored_As_Null_Object() { ServiceCollection services = new ServiceCollectionBuilder().PrepareServiceCollection(s => { s.ResetDapperCustomTypeHandlers(); s.RegisterDapperCustomTypeHandlers(Assembly.GetExecutingAssembly()); }); ServiceProvider serviceProvider = services.BuildServiceProvider(); using (IServiceScope scope = serviceProvider.CreateScope()) { var scopedServices = scope.ServiceProvider; ITestObjectRepository testObjectRepository = scopedServices.GetRequiredService <ITestObjectRepository>(); TestXmlObject testObject = new TestXmlObject { FirstName = "John", LastName = "Doe", StartWork = new DateTime(2018, 06, 01), Content = null }; // Act await testObjectRepository.SaveTestXmlObject(testObject); TestXmlObject retrievedTestObject = await testObjectRepository.GetTestXmlObject(testObject.Id); // Assert retrievedTestObject.Should().NotBeNull(); retrievedTestObject.Should().BeEquivalentTo(testObject); retrievedTestObject.Content.Should().BeEquivalentTo(testObject.Content); } }