コード例 #1
0
        public void DeleteCaseInfoSuccessTest()
        {
            var caseInfoDto = new CaseInfoDto
            {
                CaseId          = 1,
                CaseNumber      = "1",
                CourtNumber     = "1",
                Value           = 1,
                Judge           = 'F',
                Court           = "Test",
                CounterParty    = "Test",
                Note            = "Test",
                DateCreated     = DateTime.Now,
                DateModified    = DateTime.Now,
                IsDeleted       = false,
                CaseCategory    = 1,
                CustomerId      = 1,
                ClientId        = 1,
                CreatedByUserId = 1
            };

            var caseInfoRepo = new Mock <ICaseInfoRepository>();

            caseInfoRepo.Setup(x => x.DeleteCase(It.IsAny <int>()));
            var     caseInfoManipulation = new CaseInfoManipulation(caseInfoRepo.Object);
            IMapper _mapper    = new Mapper(null);
            var     controller = new CaseInfoController(caseInfoManipulation, _mapper);
            var     result     = controller.DeleteCase(1);

            Assert.IsType <OkObjectResult>(result);
        }
コード例 #2
0
        public void UpdateCaseInfoBadRequestFailureTest()
        {
            var caseInfoDto = new CaseInfoDto
            {
                CaseId          = 1,
                CaseNumber      = "1",
                CourtNumber     = "1",
                Value           = 1,
                Judge           = 'F',
                Court           = "Test",
                CounterParty    = "Test",
                Note            = "Test",
                DateCreated     = DateTime.Now,
                DateModified    = DateTime.Now,
                IsDeleted       = false,
                CaseCategory    = 1,
                CustomerId      = 1,
                ClientId        = 1,
                CreatedByUserId = 1
            };

            var caseInfoRepo = new Mock <ICaseInfoRepository>();

            caseInfoRepo.Setup(x => x.EditCaseInfoById(It.IsAny <int>(), It.IsAny <CaseInfoDto>())).Throws <Exception>();
            var     caseInfoManipulation = new CaseInfoManipulation(caseInfoRepo.Object);
            IMapper _mapper    = new Mapper(null);
            var     controller = new CaseInfoController(caseInfoManipulation, _mapper);
            var     result     = controller.Put(1, caseInfoDto);

            Assert.IsType <Boolean>(result);
        }
コード例 #3
0
        public void CreateCaseInfoNoContentFailureTest()
        {
            var caseInfoDto = new CaseInfoDto
            {
                CaseId          = 1,
                CaseNumber      = "1",
                CourtNumber     = "1",
                Value           = 1,
                Judge           = 'F',
                Court           = "Test",
                CounterParty    = "Test",
                Note            = "Test",
                DateCreated     = DateTime.Now,
                DateModified    = DateTime.Now,
                IsDeleted       = false,
                CaseCategory    = 1,
                CustomerId      = 1,
                ClientId        = 1,
                CreatedByUserId = 1
            };

            var mockRepo = new Mock <ICaseInfoManipulation>();

            mockRepo.Setup(x => x.CreateCaseInfo(It.IsAny <CaseInfoDto>()));
            IMapper _mapper    = new Mapper(null);
            var     controller = new CaseInfoController(mockRepo.Object, _mapper);
            var     result     = controller.Post(caseInfoDto);

            Assert.IsType <NoContentResult>(result);
        }
コード例 #4
0
        public void UpdateCaseInfoFailureTest()
        {
            var     mockRepo   = new Mock <ICaseInfoManipulation>();
            IMapper _mapper    = new Mapper(null);
            var     controller = new CaseInfoController(mockRepo.Object, _mapper);

            controller.ModelState.AddModelError("error", "some error");
            var result = controller.Put(1, null);

            Assert.IsType <Boolean>(result);
        }
コード例 #5
0
        public void DeleteNonExistentCaseInfoFailureTest()
        {
            // Arrange & Act
            var     mockRepo   = new Mock <ICaseInfoManipulation>();
            IMapper _mapper    = new Mapper(null);
            var     controller = new CaseInfoController(mockRepo.Object, _mapper);

            // Act
            var result = controller.DeleteCase(1);

            // Assert
            Assert.IsType <OkObjectResult>(result);
        }
コード例 #6
0
        public void getCaseByIdTest()
        {
            var caseInfo = new CaseInfo
            {
                CaseId          = 1,
                CaseNumber      = "1",
                CourtNumber     = "1",
                Value           = 1,
                Judge           = 'F',
                Court           = "Test",
                CounterParty    = "Test",
                Note            = "Test",
                DateCreated     = DateTime.Now,
                DateModified    = DateTime.Now,
                IsDeleted       = false,
                CaseCategory    = 1,
                CustomerId      = 1,
                ClientId        = 1,
                CreatedByUserId = 1
            };

            var mockRepo = new Mock <ICaseInfoRepository>();

            mockRepo.Setup(x => x.GetCaseInfoById(It.Is <int>(q => q == 1))).Returns(caseInfo);
            var     caseInfoManipulation = new CaseInfoManipulation(mockRepo.Object);
            IMapper _mapper = new Mapper(null);

            var controller     = new CaseInfoController(caseInfoManipulation, _mapper);
            var result         = controller.Get(1);
            var okObjectResult = result as OkObjectResult;

            Assert.NotNull(okObjectResult);

            var model = okObjectResult.Value as CaseInfo;

            Assert.NotNull(model);
            output.WriteLine(model.CaseNumber);
            Assert.IsType <OkObjectResult>(result);
        }
コード例 #7
0
        public void geCaseInfosTest()
        {
            var caseInfo = new CaseInfoDto
            {
                CaseId          = 1,
                CaseNumber      = "1",
                CourtNumber     = "1",
                Value           = 1,
                Judge           = 'F',
                Court           = "Test",
                CounterParty    = "Test",
                Note            = "Test",
                DateCreated     = DateTime.Now,
                DateModified    = DateTime.Now,
                IsDeleted       = false,
                CaseCategory    = 1,
                CustomerId      = 1,
                ClientId        = 1,
                CreatedByUserId = 1
            };

            var addresses = new List <CaseInfoDto>
            {
                caseInfo
            };

            var mockRepo = new Mock <ICaseInfoRepository>();

            mockRepo.Setup(x => x.GetCaseInfos()).Returns(addresses);
            var     caseInfoManipulation = new CaseInfoManipulation(mockRepo.Object);
            IMapper _mapper        = new Mapper(null);
            var     controller     = new CaseInfoController(caseInfoManipulation, _mapper);
            var     result         = controller.Get();
            var     okObjectResult = result as OkObjectResult;

            Assert.NotNull(okObjectResult);
            Assert.IsType <OkObjectResult>(result);
        }