Exemplo n.º 1
0
        public void CreateTest()
        {
            AboutDto result = _aboutManager.Create("test");

            Assert.AreEqual("test", result.Value);
            Assert.AreEqual(0, result.Id);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        public AboutDto Read(int id)
        {
            AboutDto dto = new AboutDto {
                Value = ReadValue
            };

            return(dto);
        }
Exemplo n.º 5
0
 private static AboutCommand ToCommand(this AboutDto about)
 {
     return(new AboutCommand
     {
         Body = about.Body,
         PictureCommands = about.DocumentPictures.ToCommand()
     });
 }
Exemplo n.º 6
0
        public AboutDto Create(string value)
        {
            AboutDto dto = new AboutDto {
                Value = "testCreate"
            };

            return(dto);
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 9
0
        public AboutDto Read(int id)
        {
            AboutDto dto = _dbManager.ReadHomeAbout(id);

            if (dto.Value == "test")
            {
                throw new Exception("Invalid DTO");
            }

            return(dto);
        }
Exemplo n.º 10
0
        public AboutDto Update(AboutDto dto)
        {
            bool success = _dbManager.UpdateHomeAbout(dto);

            if (!success)
            {
                throw new Exception("Unable to create DTO");
            }

            return(dto);
        }
Exemplo n.º 11
0
        public bool UpdateHomeAbout(AboutDto contactDto)
        {
            bool success = true;

            try {
                Database.HomeAbout[contactDto.Id] = contactDto;
            } catch (Exception e) {
                Console.WriteLine(e);
                success = false;
            }

            return(success);
        }
Exemplo n.º 12
0
        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);
        }
Exemplo n.º 13
0
        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);
        }
Exemplo n.º 14
0
        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);
        }
Exemplo n.º 15
0
        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));
        }
Exemplo n.º 16
0
        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);
        }
Exemplo n.º 17
0
        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);
 }
Exemplo n.º 20
0
 public AboutDto Update(AboutDto dto)
 {
     return(new AboutDto {
         Value = "testUpdate"
     });
 }
 public ComingToAbout(NavigationContext context)
 {
     Dto = new AboutDto();
     queryString = context.QueryString;
     DeserializeFromQueryString();
 }