public async Task ThrowMagicExeption_IfNullBar_Passed() { var options = TestUtils.GetOptions(nameof(ThrowMagicExeption_IfNullBar_Passed)); var fileService = new Mock <IFileUploadService>(); using (var assertContext = new CMContext(options)) { var sut = new BarServices(assertContext, fileService.Object); var ex = await Assert.ThrowsExceptionAsync <MagicException>( async() => await sut.Delete("dddd")); } }
public async Task ThrowCorrectMagicExeption_IfNullId_Passed() { var options = TestUtils.GetOptions(nameof(ThrowCorrectMagicExeption_IfNullId_Passed)); var fileService = new Mock <IFileUploadService>(); using (var assertContext = new CMContext(options)) { var sut = new BarServices(assertContext, fileService.Object); var ex = await Assert.ThrowsExceptionAsync <MagicException>( async() => await sut.Delete(null)); Assert.AreEqual("ID cannot be null!", ex.Message); } }
public async Task Return_NameOfDeletedBar_IfEverythingIsOk() { var options = TestUtils.GetOptions(nameof(Return_NameOfDeletedBar_IfEverythingIsOk)); var fileService = new Mock <IFileUploadService>(); using (var assertContext = new CMContext(options)) { var sut = new BarServices(assertContext, fileService.Object); assertContext.Bars.Add(new Bar { Id = "1", Name = "BashBar" }); await assertContext.SaveChangesAsync(); var result = await sut.Delete("1"); Assert.AreEqual(result, "BashBar"); } }
public async Task SetDateDaletedToDateTimeNow_AndSaveChangesInDb_IfValidValues_Passed() { var options = TestUtils.GetOptions(nameof(ThrowCorrectMagicExeption_IfNullBar_Passed)); var fileService = new Mock <IFileUploadService>(); using (var assertContext = new CMContext(options)) { var sut = new BarServices(assertContext, fileService.Object); assertContext.Bars.Add(new Bar { Id = "1", Name = "Bar" }); await assertContext.SaveChangesAsync(); Assert.AreEqual(null, assertContext.Bars.First().DateDeleted); await sut.Delete("1"); Assert.AreNotEqual(null, assertContext.Bars.First().DateDeleted); } }