Пример #1
0
        public void ImportCodelistShouldReturnToViewIfCsvFileIsNull()
        {
            var controller = new CodelistValuesController(RegisterItemService.Object, RegisterService.Object, AccessControlService.Object, null, null);
            var result     = controller.Import(null, "25CC9CF7-2190-4A58-B4D2-3378DE295A12") as ViewResult;

            result.Should().NotBeNull();
        }
Пример #2
0
        public void ImportCodelistShouldReturnHttpNotFoundIfRegisterIsNull()
        {
            var controller = new CodelistValuesController(null, RegisterService.Object, AccessControlService.Object, null, null);
            var result     = controller.Import(null, null) as HttpNotFoundResult;

            result.StatusCode.Should().Be(404);
        }
Пример #3
0
        public void ImportCodelistShouldReturnToViewIfCsvFileIsNull()
        {
            var controller = new CodelistValuesController(RegisterItemService.Object, RegisterService.Object, AccessControlService.Object, null, null);
            var result     = controller.Import(null, "testregister", null, null) as ViewResult;

            result.Should().NotBeNull();
        }
Пример #4
0
        public void GetImportViewIfRegisterIsNotNull()
        {
            RegisterService.Setup(r => r.GetRegisterBySystemId(System.Guid.Parse("25CC9CF7-2190-4A58-B4D2-3378DE295A12"))).Returns(Register);

            var controller = new CodelistValuesController(null, RegisterService.Object, AccessControlService.Object, null, null);
            var result     = controller.Import("25CC9CF7-2190-4A58-B4D2-3378DE295A12") as ViewResult;

            result.Should().NotBeNull();
        }
Пример #5
0
        public void GetHttpNotFoundIfRegisterIsNullWhenTryingToGetImportView()
        {
            RegisterService.Setup(r => r.GetRegister(null, "null")).Returns(Register);

            var controller = new CodelistValuesController(null, RegisterService.Object, null, null, null);
            var result     = controller.Import("") as HttpNotFoundResult;

            result.StatusCode.Should().Be(404);
        }
Пример #6
0
        public void GetImportViewIfRegisterIsNotNull()
        {
            RegisterService.Setup(r => r.GetRegister(null, "testregister")).Returns(Register);

            var controller = new CodelistValuesController(null, RegisterService.Object, AccessControlService.Object, null, null);
            var result     = controller.Import("testregister", null) as ViewResult;

            result.Should().NotBeNull();
        }
Пример #7
0
        public void ImportCodelistShouldReturnToRegisterUrlAfterImport()
        {
            var file = new Mock <HttpPostedFileBase>();

            file.Setup(f => f.ContentType).Returns("text/csv");
            var controller = new CodelistValuesController(RegisterItemService.Object, RegisterService.Object, AccessControlService.Object, null, null);
            var result     = controller.Import(file.Object, "25CC9CF7-2190-4A58-B4D2-3378DE295A12") as RedirectResult;

            result.Url.Should().Be(Register.GetObjectUrl());
        }
Пример #8
0
        public void ImportCodelistShouldSetModelErrorIfFileContentIsNotcsvContent()
        {
            var file = new Mock <HttpPostedFileBase>();

            file.Setup(f => f.ContentType).Returns("WrongContentType");
            var controller = new CodelistValuesController(RegisterItemService.Object, RegisterService.Object, AccessControlService.Object, null, null);

            controller.Import(file.Object, "25CC9CF7-2190-4A58-B4D2-3378DE295A12");
            var modelstate = controller.ModelState;

            modelstate.IsValid.Should().BeFalse();
        }