public async Task SimpleNotifyLogicSignup() { var data = new FakeApiDataEntityHandler <NotifyTemplate>(); var logic = new FakeApiLogicHandler(); var cloud = new FakeCloudHandler(); var template = NotifyTemplateData.GetFirst(); var tenant = TenantData.GetFirst(); var config = UserConfigData.GetFirst(); data.Result.Setup(m => m.Execute(It.IsAny <NotifyTemplateByName>())).Returns(template); data.Result.Setup(m => m.Execute(It.IsAny <Loader <Tenant> >())).Returns(tenant); data.Result.Setup(m => m.Execute(It.IsAny <Loader <UserConfig> >())).Returns(config); cloud.Result.Setup(m => m.Execute(It.IsAny <EmailTemplateCmd>())) .Returns(ActionConfirm.CreateSuccess("Sent")); var command = new SimpleNotify { DataHandler = data, CurrentUser = StandardUser, TemplateName = "signup", CloudHandler = cloud, LogicHandler = logic, Model = tenant }; await command.Execute(); cloud.HasExecuted.Should().BeTrue(); data.HasExecuted.Should().BeTrue(); data.HasCommitted.Should().BeFalse(); data.Result.Verify(s => s.Execute(It.IsAny <NotifyTemplateByName>()), Times.Once()); data.Result.Verify(s => s.Execute(It.IsAny <Loader <Tenant> >()), Times.Once()); }
public async Task ChangeConfigLogicConfigSetUnauthorized() { var data = new UserApiDataHandler(); var model = UserData.GetFirst(); var config = UserConfigData.GetFirst(); data.Result.Setup(m => m.Execute(It.IsAny <UserById>())).Returns(model); data.Result.Setup(m => m.Execute(It.IsAny <Persist <User> >())).Returns(model); var command = new ChangeConfig { DataHandler = data, CurrentUser = NonTenantUser, Key = "CANAUTH", Value = "true", ResultConfig = config, UserId = StandardUser.Id }; await command.Execute(); data.HasExecuted.Should().BeTrue(); data.HasCommitted.Should().BeFalse(); data.Result.Verify(s => s.Execute(It.IsAny <Persist <User> >()), Times.Never()); }
public async Task UserConfigControllerSetWithLogic() { var data = new UserConfigApiDataHandler(); var user = StandardUser; var config = UserConfigData.GetFirst(); Logic.Result.Setup(m => m.Execute(It.IsAny <ChangeConfig>())).Returns(true); var controller = new ConfigController(data, Logic) { CurrentUser = StandardUser, CurrentConfig = config }; var result = await controller.Set("TemplateView", "list") as OkObjectResult; result.Should().NotBeNull(); result.Should().BeOfType <OkObjectResult>(); var viewModel = result.Value as ConfigViewModel; viewModel.Success.Should().BeTrue(); Logic.HasExecuted.Should().BeTrue(); data.HasExecuted.Should().BeFalse(); data.HasCommitted.Should().BeTrue(); }
public async Task SigninAuthLogicSignup() { var logic = new CoreApiLogicHandler(); logic.Result.Setup(m => m.Execute(It.IsAny <WriteToken>())).Returns(true); var command = new SigninAuth { LogicHandler = logic, Login = StandardUser, Config = UserConfigData.GetFirst(), Tenant = TenantData.GetFirst(), Settings = new FakeSettings() }; await command.Execute(); logic.HasExecuted.Should().BeTrue(); logic.Result.Should().NotBeNull(); command.Result.Verification.Should().BeNullOrEmpty(); command.Result.Key.Should().NotBeNullOrEmpty(); command.Result.Message.Should().BeNullOrEmpty(); command.Result.Config.Should().NotBeNull(); command.Result.Id.Should().NotBeNullOrEmpty(); command.Result.Success.Should().BeTrue(); }
public static AuthViewModel GetAuth() { return(new AuthViewModel { Id = UserData.FirstId, Success = true, Message = string.Empty, Verification = "xxx111key", Key = EncryptHelper.Encrypt(UserData.FirstId + Keys.Salty), Config = UserConfigData.GetFirst(), }); }
protected override void SetupDatabase(IDocumentStore store) { store.ExecuteIndex(new UserIndex()); using (var session = store.OpenSession()) { session.Store(UserData.GetFirst()); session.Store(UserConfigData.GetFirst()); session.SaveChanges(); } WaitForIndexing(store); }
public async Task ChangeConfigLogicConfigSetDefault(string key, string value) { var data = new UserConfigApiDataHandler(); var config = UserConfigData.GetFirst(); var command = new ChangeConfig { DataHandler = data, CurrentUser = StandardUser, Key = key, Value = value, ResultConfig = config, UserId = StandardUser.Id }; await command.Execute(); data.HasExecuted.Should().BeFalse(); data.HasCommitted.Should().BeFalse(); data.Result.Verify(s => s.Execute(It.IsAny <Persist <UserConfig> >()), Times.Never()); }
public async Task UserConfigControllerGet() { var data = new UserConfigApiDataHandler(); var user = StandardUser; var config = UserConfigData.GetFirst(); var tenant = TenantData.GetFirstDisplay(); data.Result.Setup(m => m.Execute(It.IsAny <TenantDisplayById>())).Returns(tenant); var controller = new ConfigController(data, Logic) { CurrentUser = StandardUser, CurrentConfig = config }; var result = await controller.Get() as OkObjectResult; result.Should().NotBeNull(); result.Should().BeOfType <OkObjectResult>(); result.Value.Should().BeOfType <CurrentViewModel>(); var check = result.Value as CurrentViewModel; check.StorageLimit.Should().Be(tenant.StorageLimit); check.FileCount.Should().Be(tenant.FileCount); check.FileSize.Should().Be(tenant.FileSize); check.UserLimit.Should().Be(tenant.UserLimit); check.Config.TemplateView.Should().Be(config.TemplateView); check.Config.Id.Should().Be(config.Id); check.Config.TenantId.Should().Be(config.TenantId); check.UserCount.Should().Be(0); check.TenantId.Should().Be(config.TenantId); check.Id.Should().Be(user.Id); check.Right.CanSuperuser.Should().BeFalse(); check.Right.CanAdmin.Should().BeFalse(); check.Right.CanAuth.Should().BeFalse(); data.HasExecuted.Should().BeTrue(); data.HasCommitted.Should().BeFalse(); data.Result.Verify(s => s.Execute(It.IsAny <TenantDisplayById>()), Times.Once); }