Exemple #1
0
        public async Task Group_Create_WithUnknownWarning_IgnoresIt()
        {
            InjectBasicLAsAndGroupTypes();
            GetMock <IGroupsWriteService>().Setup(x => x.ValidateAsync(It.IsAny <SaveGroupDto>(), It.IsAny <IPrincipal>())).ReturnsAsync(new ValidationEnvelopeDto {
                Warnings = new List <ApiWarning> {
                    new ApiWarning {
                        Code = "unknown", Message = "similar"
                    }
                }
            });
            GetMock <IGroupsWriteService>().Setup(x => x.SaveNewAsync(It.IsAny <SaveGroupDto>(), It.IsAny <IPrincipal>())).ReturnsAsync(new ApiResponse <NumericResultDto>(true)
            {
                Response = new NumericResultDto {
                    Value = 123
                }
            });
            GetMock <IGroupReadService>().Setup(x => x.ExistsAsync(It.IsAny <IPrincipal>(), It.IsAny <CompaniesHouseNumber?>(), It.IsAny <string>(), It.IsAny <int?>(), It.IsAny <string>(), It.IsAny <int?>())).ReturnsAsync(false);
            GetMock <ISecurityService>().Setup(x => x.CreateAnonymousPrincipal()).Returns(new GenericPrincipal(new GenericIdentity(""), new string[0]));

            var result = (RedirectToRouteResult)await ObjectUnderTest.Create(new GroupEditorViewModel
            {
                GroupName         = "test group",
                Action            = ActionSave,
                GroupTypeId       = (int)eLookupGroupType.Federation,
                OpenDate          = new Web.UI.Models.DateTimeViewModel(DateTime.Now),
                ProcessedWarnings = true
            }, ActionSave);

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