public async Task SignupUserLogic() { var data = new SignupDataHandler(); var logic = new CoreApiLogicHandler(); var cloud = new FakeCloudHandler(); var tenant = TenantData.GetFirst(); var viewModel = LoginData.GetSignup(); data.Result.Setup(m => m.Execute(It.IsAny <Loader <Tenant> >())).Returns(tenant); data.Result.Setup(m => m.Execute(It.IsAny <UserSave>())).Returns(StandardUser); logic.Result.Setup(m => m.Execute(It.IsAny <SimpleNotify>())).Returns(ActionConfirm.CreateSuccess("Worked")); var command = new SignupUser { DataHandler = data, CloudHandler = cloud, LogicHandler = logic, Input = viewModel }; await command.Execute(); logic.HasExecuted.Should().BeTrue(); logic.Result.Verify(s => s.Execute(It.IsAny <SimpleNotify>()), Times.Once()); data.HasExecuted.Should().BeTrue(); data.HasCommitted.Should().BeTrue(); data.Result.Verify(s => s.Execute(It.IsAny <Loader <Tenant> >()), Times.Once()); data.Result.Verify(s => s.Execute(It.IsAny <UserSave>()), Times.AtLeastOnce()); }
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 async Task TenantControllerPost() { var data = new FakeApiDataEntityHandler <Tenant>(); var model = TenantData.GetFirst(); data.Result.Setup(m => m.Execute(It.IsAny <Loader <Tenant> >())).Returns(model); data.Result.Setup(m => m.Execute(It.IsAny <TenantSave>())).Returns(model); var controller = new TenantController(data, Logic) { CurrentUser = SuperUser }; var viewModel = controller.Mapper.Map <TenantViewModel>(model); var result = await controller.Post(viewModel) as OkObjectResult; result.Should().NotBeNull(); result.Should().BeOfType <OkObjectResult>(); result.Value.Should().NotBeNull(); var check = result.Value as ConfirmViewModel; check.Success.Should().BeTrue(); data.HasExecuted.Should().BeTrue(); data.HasCommitted.Should().BeTrue(); data.Result.Verify(s => s.Execute(It.IsAny <TenantSave>()), Times.Once); }
public async Task TenantControllerGet() { var data = new FakeApiDataEntityHandler <Tenant>(); var model = TenantData.GetFirst(); data.Result.Setup(m => m.Execute(It.IsAny <Loader <Tenant> >())).Returns(model); var controller = new TenantController(data, Logic) { CurrentUser = AdminUser }; var result = await controller.Get(TenantData.FirstId) as OkObjectResult; result.Should().NotBeNull(); result.Should().BeOfType <OkObjectResult>(); result.Value.Should().NotBeNull(); var check = result.Value as TenantViewModel; check.ProfileId.Should().Be(model.ProfileId); check.ProfileThumbUrl.Should().Be(model.ProfileThumbUrl); data.HasExecuted.Should().BeTrue(); data.HasCommitted.Should().BeFalse(); data.Result.Verify(s => s.Execute(It.IsAny <Loader <Tenant> >()), Times.Once); }
public async Task SimpleNotifyLogicSignupMissingTemplate() { var data = new FakeApiDataEntityHandler <NotifyTemplate>(); var logic = new FakeApiLogicHandler(); var cloud = new FakeCloudHandler(); var template = NotifyTemplateData.GetFirst(); var tenant = TenantData.GetFirst(); data.Result.Setup(m => m.Execute(It.IsAny <NotifyTemplateByName>())).Returns(null); var command = new SimpleNotify { DataHandler = data, CurrentUser = StandardUser, TemplateName = "signup", CloudHandler = cloud, LogicHandler = logic, Model = tenant, Result = ActionConfirm.CreateFailure("It failed") }; await command.Execute(); command.Result.Success.Should().BeFalse(); cloud.HasExecuted.Should().BeFalse(); 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.Never()); }
protected override void SetupDatabase(IDocumentStore store) { using var session = store.OpenSession(); session.Store(TenantData.GetFirst()); session.Store(UserData.GetFirst()); session.SaveChanges(); }
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()); }
protected override void SetupDatabase(IDocumentStore store) { store.ExecuteIndex(new TenantIndex()); store.ExecuteIndex(new OwnedMasterIndex()); using var session = store.OpenSession(); session.Store(TenantData.GetFirst()); session.SaveChanges(); WaitForIndexing(store); }
public async Task TenantByEntryKeyDataTest() { using var store = GetDocumentStore(); using var session = store.OpenAsyncSession(); var loader = new TenantByEntryKey { Session = session, EntryKey = "first" }; await loader.Execute(); loader.Result.Should().NotBeNull(); loader.Result.Id.Should().Be(TenantData.FirstId); Assert.That(loader.Result, Is.DeepEqualTo(TenantData.GetFirst())); }
public void TenantMasterTest() { var config = new MapperConfiguration(cfg => { cfg.CreateMap <Tenant, TenantMaster>(); cfg.CreateMap <TenantMaster, Tenant>(); }); var mapper = new Mapper(config); var master = mapper.Map <TenantMaster>(TenantData.GetFirst()); var document = mapper.Map <Tenant>(master); master.Should().NotBeNull(); document.Should().NotBeNull(); }
public async Task LoadersDataTest() { using var store = GetDocumentStore(); using var session = store.OpenAsyncSession(); var loader = new Loaders <Tenant> { Session = session, Ids = new List <string> { TenantData.FirstId } }; await loader.Execute(); loader.Result.Should().NotBeNull(); loader.Result.First().Id.Should().Be(TenantData.FirstId); Assert.That(loader.Result.First(), Is.DeepEqualTo(TenantData.GetFirst())); }
protected override void SetupDatabase(IDocumentStore store) { store.ExecuteIndex(new MeetingIndex()); store.ExecuteIndex(new MsgIndex()); store.ExecuteIndex(new AttendanceIndex()); store.ExecuteIndex(new TenantStatIndex()); using (var session = store.OpenSession()) { session.Store(MeetingData.GetFirst()); session.Store(MsgData.GetFirst()); session.Store(AttendanceData.GetFirst()); session.Store(TenantData.GetFirst()); session.SaveChanges(); } WaitForIndexing(store); }
public async Task TenantControllerGetFail() { var data = new FakeApiDataEntityHandler <Tenant>(); var model = TenantData.GetFirst(); data.Result.Setup(m => m.Execute(It.IsAny <Loader <Tenant> >())).Returns(model); var controller = new TenantController(data, Logic) { CurrentUser = NonTenantUser }; var result = await controller.Get(TenantData.FirstId) as UnauthorizedResult; result.Should().NotBeNull(); result.Should().BeOfType <UnauthorizedResult>(); data.HasExecuted.Should().BeTrue(); data.HasCommitted.Should().BeFalse(); data.Result.Verify(s => s.Execute(It.IsAny <Loader <Tenant> >()), Times.Once); }
public async Task TenantControllerDeleteNotFound() { var data = new FakeApiDataEntityHandler <Tenant>(); var model = TenantData.GetFirst(); data.Result.Setup(m => m.Execute(It.IsAny <Loader <Tenant> >())).Returns(null); data.Result.Setup(m => m.Execute(It.IsAny <TenantDelete>())).Returns(false); var controller = new TenantController(data, Logic) { CurrentUser = StandardUser }; var result = await controller.Delete(TenantData.FirstId) as NotFoundResult; result.Should().NotBeNull(); result.Should().BeOfType <NotFoundResult>(); data.HasExecuted.Should().BeTrue(); data.HasCommitted.Should().BeFalse(); data.Result.Verify(s => s.Execute(It.IsAny <Loader <Tenant> >()), Times.Once); data.Result.Verify(s => s.Execute(It.IsAny <TenantDelete>()), Times.Never); }
public void TenantStatTest() { var config = new MapperConfiguration(cfg => { cfg.CreateMap <Tenant, TenantStat>(); cfg.CreateMap <TenantStat, Tenant>(); }); var mapper = new Mapper(config); var master = mapper.Map <TenantStat>(TenantData.GetFirst()); var document = mapper.Map <Tenant>(master); master.FileCount = 1; master.FileSize = 1; master.UserCount = 1; master.FileCount.Should().Be(1); master.FileSize.Should().Be(1); master.UserCount.Should().Be(1); master.Should().NotBeNull(); document.Should().NotBeNull(); }
public async Task SignupControllerAuthTest() { var data = new SignupDataHandler(); var logic = new CoreApiLogicHandler(); var entry = SignupData.GetEntry(); data.Result.Setup(m => m.Execute(It.IsAny <TenantByEntryKey>())).Returns(TenantData.GetFirst()); var controller = new SignupController(data, Cloud, logic); var result = await controller.Entry(entry) as OkObjectResult; result.Should().NotBeNull(); result.Should().BeOfType <OkObjectResult>(); Assert.That(result.Value, Is.DeepEqualTo(entry)); logic.HasExecuted.Should().BeFalse(); data.HasExecuted.Should().BeTrue(); data.HasCommitted.Should().BeFalse(); data.Result.Verify(s => s.Execute(It.IsAny <TenantByEntryKey>()), Times.Once); }
public async Task TenantControllerPostUnauthorized() { var data = new FakeApiDataEntityHandler <Tenant>(); var model = TenantData.GetFirst(); data.Result.Setup(m => m.Execute(It.IsAny <Loader <Tenant> >())).Returns(model); data.Result.Setup(m => m.Execute(It.IsAny <TenantSave>())).Returns(model); var controller = new TenantController(data, Logic) { CurrentUser = StandardUser }; var viewModel = controller.Mapper.Map <TenantViewModel>(model); var result = await controller.Post(viewModel) as UnauthorizedResult; result.Should().NotBeNull(); result.Should().BeOfType <UnauthorizedResult>(); data.HasExecuted.Should().BeTrue(); data.HasCommitted.Should().BeFalse(); data.Result.Verify(s => s.Execute(It.IsAny <TenantSave>()), Times.Never); }