Exemple #1
0
        public async Task Group_SaveNewAcademyTrust()
        {
            var gws = GetMock <IGroupsWriteService>();

            gws.Setup(x => x.ValidateAsync(It.IsAny <SaveGroupDto>(), It.IsAny <IPrincipal>())).ReturnsAsync(new ValidationEnvelopeDto());
            gws.Setup(x => x.SaveNewAsync(It.IsAny <SaveGroupDto>(), It.IsAny <IPrincipal>())).ReturnsAsync(new ApiResponse <NumericResultDto>(true)
            {
                Response = new NumericResultDto {
                    Value = 123
                }
            });

            GetMock <ISecurityService>().Setup(x => x.GetCreateGroupPermissionAsync(It.IsAny <IPrincipal>()))
            .ReturnsAsync(new CreateGroupPermissionDto {
                GroupTypes = new eLookupGroupType[] { eLookupGroupType.MultiacademyTrust }
            });


            var vm = new CreateAcademyTrustViewModel
            {
                CompaniesHouseAddressToken = UriHelper.SerializeToUrlToken(new AddressDto {
                    Line1 = "line1", CityOrTown = "Bobville"
                }),
                CompaniesHouseNumber = "67362546543",
                TypeId   = (int)eLookupGroupType.MultiacademyTrust,
                Name     = "Multi acad",
                OpenDate = DateTime.Now,
                GroupId  = "54243"
            };
            var result = (RedirectToRouteResult)await ObjectUnderTest.SaveNewAcademyTrust(vm);

            Assert.That(result.RouteValues["action"], Is.EqualTo("Details"));
            Assert.That(result.RouteValues["id"], Is.EqualTo(123));
        }