public void CreateTest() { AboutDto result = _aboutManager.Create("test"); Assert.AreEqual("test", result.Value); Assert.AreEqual(0, result.Id); }
public void TestCreateHomeAbout2() { DatabaseManager databaseManager = new DatabaseManager(); AboutDto aboutDto = new AboutDto(); aboutDto.Id = 3; aboutDto.Value = "value"; AboutDto aboutDto2 = new AboutDto(); aboutDto2.Id = 3; aboutDto2.Value = "value"; _createdDtoList.Add(aboutDto); bool result = databaseManager.CreateHomeAbout(aboutDto); databaseManager.CreateHomeAbout(aboutDto2); Assert.IsTrue(result); AboutDto resultDto = databaseManager.ReadHomeAbout(1); Assert.AreEqual(aboutDto.Id, resultDto.Id); Assert.AreEqual(aboutDto.Value, resultDto.Value); }
public AboutDto EditAbout(AboutDto AboutDto, int userId, int tenantId) { var AboutObj = _AboutService.Query(x => x.AboutId == AboutDto.AboutId && x.TenantId == tenantId).Select().FirstOrDefault(); if (AboutObj == null) { throw new NotFoundException(ErrorCodes.ProductNotFound); } foreach (var AboutName in AboutDto.DescriptionDictionary) { var AboutTranslation = AboutObj.AboutTranslations.FirstOrDefault(x => x.Language.ToLower() == AboutName.Key.ToLower() && x.AboutId == AboutDto.AboutId); if (AboutTranslation == null) { AboutObj.AboutTranslations.Add(new AboutTranslation { Description = AboutName.Value, Language = AboutName.Key }); } else { AboutTranslation.Description = AboutName.Value; } } AboutObj.LastModificationTime = Strings.CurrentDateTime; AboutObj.LastModifierUserId = userId; AboutObj.VideoUrl = AboutDto.VideoUrl; _AboutService.Update(AboutObj); SaveChanges(); return(AboutDto); }
public AboutDto Read(int id) { AboutDto dto = new AboutDto { Value = ReadValue }; return(dto); }
private static AboutCommand ToCommand(this AboutDto about) { return(new AboutCommand { Body = about.Body, PictureCommands = about.DocumentPictures.ToCommand() }); }
public AboutDto Create(string value) { AboutDto dto = new AboutDto { Value = "testCreate" }; return(dto); }
public void ReadTest() { AboutDto result = _aboutManager.Read(1); Assert.IsNotNull(result); Assert.AreEqual(0, result.Id); Assert.IsNull(result.Value); }
public void TestHomeControllerAbout() { //Act ActionResult result = _homeController.About(); //Assert AboutDto resultDto = GetAboutDto(result); Assert.AreEqual(AboutManagerTesting.ReadValue, resultDto.Value); }
public AboutDto Read(int id) { AboutDto dto = _dbManager.ReadHomeAbout(id); if (dto.Value == "test") { throw new Exception("Invalid DTO"); } return(dto); }
public AboutDto Update(AboutDto dto) { bool success = _dbManager.UpdateHomeAbout(dto); if (!success) { throw new Exception("Unable to create DTO"); } return(dto); }
public bool UpdateHomeAbout(AboutDto contactDto) { bool success = true; try { Database.HomeAbout[contactDto.Id] = contactDto; } catch (Exception e) { Console.WriteLine(e); success = false; } return(success); }
public AboutDto ReadHomeAbout(int id) { AboutDto dto = new AboutDto(); //Stored procedure or query try { List <AboutDto> results = Database.HomeAbout; dto = results[id]; } catch (Exception e) { Console.WriteLine(e); } return(dto); }
public AboutDto Create(string value) { AboutDto dto = new AboutDto { Value = value }; bool success = _dbManager.CreateHomeAbout(dto); if (!success) { throw new Exception("Unable to create DTO"); } return(dto); }
public bool CreateHomeAbout(AboutDto value) { bool success = true; try { bool exists = Database.HomeAbout.Any(m => m.Value == value.Value); if (!exists) { Database.HomeAbout.Add(value); } } catch (Exception e) { Console.WriteLine(e); success = false; } return(success); }
public void UpdateExceptionTest() { //arrange Mock <IDatabaseManager> mockDbManager = new Mock <IDatabaseManager>(); mockDbManager.Setup(m => m.UpdateHomeAbout(It.IsAny <AboutDto>())).Throws(new Exception()); AboutDto testDto = new AboutDto { Id = 1, Value = "test" }; _aboutManager = new AboutManager(mockDbManager.Object); //Act Assert.Throws <Exception>(() => _aboutManager.Update(testDto)); mockDbManager.Verify(m => m.UpdateHomeAbout(It.IsAny <AboutDto>()), Times.Exactly(1)); }
public void UpdateTest() { //arrange Mock <IDatabaseManager> mockDbManager = new Mock <IDatabaseManager>(); mockDbManager.Setup(m => m.UpdateHomeAbout(It.IsAny <AboutDto>())).Returns(true); AboutDto testDto = new AboutDto { Id = 1, Value = "test" }; _aboutManager = new AboutManager(mockDbManager.Object); //Act AboutDto resultDto = _aboutManager.Update(testDto); //Assert Assert.AreEqual(testDto.Id, resultDto.Id); Assert.AreEqual(testDto.Value, resultDto.Value); }
public void TestHomeControllerAbout() { AboutDto aboutDto = new AboutDto(); aboutDto.Id = 2; aboutDto.Value = "test"; _mockAboutManager.Setup(m => m.Read(It.IsAny <int>())).Returns(aboutDto).Verifiable(); //Act ActionResult result = _homeController.About(); _mockAboutManager.VerifyAll(); _mockAboutManager.Verify(m => m.Read(It.IsAny <int>()), Times.Once); //Assert AboutDto resultDto = GetAboutDto(result); Assert.AreEqual(aboutDto.Value, resultDto.Value); Assert.AreEqual(aboutDto.Id, resultDto.Id); }
public bool UpdateHomeAbout(AboutDto contactDto) { return(true); }
public bool CreateHomeAbout(AboutDto value) { return(true); }
public AboutDto Update(AboutDto dto) { return(new AboutDto { Value = "testUpdate" }); }
public ComingToAbout(NavigationContext context) { Dto = new AboutDto(); queryString = context.QueryString; DeserializeFromQueryString(); }