public async Task CreateShouldSucceed() { //Arrange var code = "TestCode"; var name = "TestName"; var source = "TestSource"; var damagedQuantityRequired = true; var damageCode = new DamageCode(Guid.NewGuid(), code, name, damagedQuantityRequired, source); //Act await _repository.CreateAsync(damageCode); //Asssert var data = RepositoryHelper.ForDamageCode.GetDamageCodes(); data.Should().HaveCount(1); var result = data.First(); result.Name.Should().Be(name); result.Code.Should().Be(code); result.Source.Should().Be(source); }
public static DamageCode CreateDamageCode(Guid id, string code, string name, bool DamagedQuantityRequired, string source) { // prepare var writeRepository = new DamageCodeWriteRepository(new DataContext(new PersistenceConfiguration(RepositoryTestsHelper.ConnectionString))); var readRepository = new DamageCodeReadRepository(new DataContext(new PersistenceConfiguration(RepositoryTestsHelper.ConnectionString))); // create var damageCode = new DamageCode(id, code, name, DamagedQuantityRequired, source); IEnumerable <DamageCode> damageCodes = new List <DamageCode>() { damageCode }; foreach (var item in damageCodes) { writeRepository.CreateAsync(item).GetAwaiter().GetResult(); } // result var result = readRepository.GetAsync(damageCode.Id).Result; return(result); }