public async Task Throws_If_Firemen_Deleted_Property_Will_Be_True_UpdateFiremenAsync() { var firemen = new Firemen { Id = 3, Name = "Jan", Surname = "Kowalski", Birthdate = DateTime.Today, City = "Kraków", DigitalCode = "31-231", Son_Daughter = "Stefana", Street = "Jasnogórska", Pesel = "87542165874", Management = true, HouseNumber = "146B", Gender = Gender.Male, Active = true, Function = "Kierowca", FlatNumber = 5, Deleted = true }; using (var context = new AppDbContext(options)) { var firemenService = new FiremenService(context, userManager.Object, httpContextAccessor.Object); await firemenService.CreateFiremenAsync(firemen); Assert.ThrowsAsync <Exception>(async() => await firemenService.UpdateFiremenAsync(firemen)); } }
public void Throws_If_Firemen_ID_Wont_Be_Greater_Than_Zero_UpdateFiremenAsync(int id) { var firemen = new Firemen { Id = id, Name = "Jan", Surname = "Kowalski", Birthdate = DateTime.Today, City = "Kraków", DigitalCode = "31-231", Son_Daughter = "Stefana", Street = "Jasnogórska", Pesel = "87542165874", Management = true, HouseNumber = "146B", Gender = Gender.Male, Active = true, Function = "Kierowca", FlatNumber = 5, }; using (var context = new AppDbContext(options)) { var firemenService = new FiremenService(context, userManager.Object, httpContextAccessor.Object); Assert.ThrowsAsync <ArgumentException>(async() => await firemenService.UpdateFiremenAsync(firemen)); } }
public void Throws_If_Firemen_Entity_Will_Be_Null_UpdateFiremenAsync() { using (var context = new AppDbContext(options)) { var firemenService = new FiremenService(context, userManager.Object, httpContextAccessor.Object); Assert.ThrowsAsync <ArgumentNullException>(async() => await firemenService.UpdateFiremenAsync(null)); } }
public async Task UpdateFiremenAsyncTest() { var firemen = new Firemen { Id = 2, Name = "Jan", Surname = "Kowalski", Birthdate = DateTime.Today, City = "Kraków", DigitalCode = "31-231", Son_Daughter = "Stefana", Street = "Jasnogórska", Pesel = "87542165874", Management = true, HouseNumber = "146B", Gender = Gender.Male, Active = true, Function = "Kierowca", FlatNumber = 5, }; var editedFiremen = new Firemen { Id = 2, Name = "Justyna", Surname = "Wierna", Birthdate = DateTime.Today, City = "Katowice", DigitalCode = "32-065", Son_Daughter = "Marka", Street = "BakerStreet", Pesel = "56482548796", Management = false, HouseNumber = "221B", Gender = Gender.Female, Active = false, Function = "Stra¿ak-Ratownik", FlatNumber = 6, ApplicationUser = new ApplicationUser { } }; using (var context = new AppDbContext(options)) { var firemenService = new FiremenService(context, userManager.Object, httpContextAccessor.Object); await firemenService.CreateFiremenAsync(firemen); context.Entry(firemen).State = EntityState.Detached; var result = await firemenService.UpdateFiremenAsync(editedFiremen); var foundFiremen = await context.Firemens.FindAsync(2); Assert.IsNotNull(result); Assert.That(foundFiremen.Name == "Justyna"); Assert.That(foundFiremen.Surname == "Wierna"); Assert.That(foundFiremen.Birthdate.Equals(DateTime.Today)); Assert.That(foundFiremen.City == "Katowice"); Assert.That(foundFiremen.DigitalCode == "32-065"); Assert.That(foundFiremen.Street == "BakerStreet"); Assert.That(foundFiremen.Pesel == "56482548796"); Assert.That(foundFiremen.Son_Daughter == "Marka"); Assert.That(!foundFiremen.Management); Assert.That(foundFiremen.HouseNumber == "221B"); Assert.That(foundFiremen.Gender == Gender.Female); Assert.That(!foundFiremen.Active); Assert.That(foundFiremen.Function == "Stra¿ak-Ratownik"); Assert.That(foundFiremen.FlatNumber == 6); Assert.IsNotNull(foundFiremen.UpdatedAt); Assert.IsNotNull(foundFiremen.UpdatedBy); } }