Exemple #1
0
        public void Test_Get_傳入部門編號陣列_預期_回傳對應部門資料()
        {
            // arrange
            var dummyData = DummyData();
            this.SMDepartmentService.Get(Arg.Any<Service.DTOs.SMDepartmentParameterDto>())
                .Returns(dummyData);

            var controller = this.GetSystemUnderTestInstance();

            var responseId = new Guid("431C5A69-6464-422E-B79D-8A206069145C");
            controller.ResponseId = responseId;

            var parameter = new Models.ParameterModels.SMDepartmentParameter
            {
                DeptIds = new string[] { "MLE" }
            };

            // 預期資料
            var expected = new SuccessOutputModel<List<Models.OutputModels.SMDepartmentViewModel>>()
            {
                ApiVersion = "1.0.0",
                Method = "/deptemp/department/get.GET",
                Data = new List<Models.OutputModels.SMDepartmentViewModel>
                {
                    new Models.OutputModels.SMDepartmentViewModel
                    {
                        DeptId = "MDK",
                        DeptLevel = 6,
                        DeptName = "資安中心",
                        EndDate = null,
                        OrderNum = 130102,
                        ParentDeptId = "MLE"
                    },
                    new Models.OutputModels.SMDepartmentViewModel
                    {
                         DeptId = "MEH",
                         DeptLevel = 6,
                         DeptName = "架構中心",
                         EndDate = null,
                         OrderNum = 130104,
                         ParentDeptId = "MLE"
                    },
                    new Models.OutputModels.SMDepartmentViewModel
                    {
                         DeptId = "MLC",
                         DeptLevel = 6,
                         DeptName = "研發中心",
                         EndDate = null,
                         OrderNum = 130103,
                         ParentDeptId = "MLE"
                    },
                    new Models.OutputModels.SMDepartmentViewModel
                    {
                         DeptId = "MLE",
                         DeptLevel = 6,
                         DeptName = "資訊處(部)",
                         EndDate = null,
                         OrderNum = 130100,
                         ParentDeptId = "MLE"
                    },
                    new Models.OutputModels.SMDepartmentViewModel
                    {
                         DeptId = "MLF",
                         DeptLevel = 6,
                         DeptName = "專案輔導中心",
                         EndDate = null,
                         OrderNum = 130101,
                         ParentDeptId = "MLE"
                    }
                },
                Id = responseId
            };

            // act
            HttpResponseMessage actual = controller.Get(parameter);

            SuccessOutputModel<List<Models.OutputModels.SMDepartmentViewModel>> actualResultModel;
            actual.TryGetContentValue(out actualResultModel).Should().BeTrue();

            // assert
            actualResultModel.ToExpectedObject().ShouldEqual(expected);
        }
Exemple #2
0
        public void Test_Get_沒有傳入必要參數_預期_拋出_validationException()
        {
            // arrange
            var controller = this.GetSystemUnderTestInstance();

            var parameter = new Models.ParameterModels.SMDepartmentParameter
            {
                IsValidOnly = true
            };

            // act
            var actual = controller.Get(null);
        }