Пример #1
0
        public async Task UserControllerFilter()
        {
            var data = new FakeApiDataResultHandler <Tenant, TenantDisplay>();
            var list = new List <TenantDisplay> {
                TenantData.GetFirstDisplay()
            };
            var filter = new TenantFilter {
                TenantRestrict = true
            };

            data.Result.Setup(m => m.Execute(It.IsAny <TenantDisplayByFilter>())).Returns(list);

            var controller = new TenantController(data, Logic)
            {
                CurrentUser = SuperUser
            };
            var result = await controller.Filter(filter) as OkObjectResult;

            result.Should().NotBeNull();
            result.Should().BeOfType <OkObjectResult>();
            result.Value.Should().NotBeNull();

            var check = result.Value as PagedResult <IEnumerable <TenantDisplay> >;

            check.Should().NotBeNull();
            check.Data.Count().Should().Be(list.Count);

            Assert.That(check.Data, Is.DeepEqualTo(list));

            data.HasExecuted.Should().BeTrue();
            data.Result.Verify(s => s.Execute(It.IsAny <TenantDisplayByFilter>()), Times.Once());
        }
Пример #2
0
        public async Task TenantDisplayByIdDataTest()
        {
            using var store   = GetDocumentStore();
            using var session = store.OpenAsyncSession();
            var query = new TenantDisplayById {
                Session = session, Id = TenantData.FirstId
            };
            await query.Execute();

            query.Result.Should().NotBeNull();
            query.Result.Id.Should().Be(TenantData.FirstId);
            query.Result.Searchable.Should().BeEmpty();
            Assert.That(query.Result, Is.DeepEqualTo(TenantData.GetFirstDisplay()));
        }
Пример #3
0
        public async Task TenantDisplayByFilterDataTestSearch()
        {
            var filter = new TenantFilter {
                Search = "Org", Take = 10
            };

            using var store   = GetDocumentStore();
            using var session = store.OpenAsyncSession();
            var query = new TenantDisplayByFilter {
                Session = session, Filter = filter, CurrentUser = StandardUser
            };
            await query.Execute();

            query.Result.Should().NotBeNull();
            query.Result.Count().Should().Be(1);
            Assert.That(query.Result.First(), Is.DeepEqualTo(TenantData.GetFirstDisplay()));
        }
Пример #4
0
        public async Task TenantControllerDisplayUnauthorized()
        {
            var data    = new FakeApiDataResultHandler <Tenant, TenantDisplay>();
            var display = TenantData.GetFirstDisplay();

            data.Result.Setup(m => m.Execute(It.IsAny <TenantDisplayById>())).Returns(display);

            var controller = new TenantController(data, Logic)
            {
                CurrentUser = NonTenantUser
            };
            var result = await controller.Display(TenantData.FirstId) as UnauthorizedResult;

            result.Should().NotBeNull();
            result.Should().BeOfType <UnauthorizedResult>();

            data.HasExecuted.Should().BeFalse();
            data.Result.Verify(s => s.Execute(It.IsAny <UserDisplayById>()), Times.Never());
        }
Пример #5
0
        public async Task StatsCompositeDataTest()
        {
            using var store   = GetDocumentStore();
            using var session = store.OpenAsyncSession();

            var query = new StatsComposite()
            {
                Session = session, CurrentUser = UserData.GetFirst()
            };
            await query.Execute();

            query.Result.Should().NotBeNull();
            query.Result.Meetings.Count().Should().Be(0);
            query.Result.Msgs.Count().Should().Be(0);
            Assert.That(query.Result.Tenant, Is.DeepEqualTo(TenantData.GetFirstDisplay()));
            query.Result.Searchable.Should().BeNullOrEmpty();
            query.Result.Searchable = new List <string> {
                "something!"
            };
        }
Пример #6
0
        public async Task TenantControllerDisplay()
        {
            var data    = new FakeApiDataResultHandler <Tenant, TenantDisplay>();
            var display = TenantData.GetFirstDisplay();

            data.Result.Setup(m => m.Execute(It.IsAny <TenantDisplayById>())).Returns(display);

            var controller = new TenantController(data, Logic)
            {
                CurrentUser = StandardUser
            };
            var result = await controller.Display(TenantData.FirstId) as OkObjectResult;

            result.Should().NotBeNull();
            result.Should().BeOfType <OkObjectResult>();

            Assert.That(result.Value, Is.DeepEqualTo(display));

            data.HasExecuted.Should().BeTrue();
            data.Result.Verify(s => s.Execute(It.IsAny <TenantDisplayById>()), Times.Once());
        }
Пример #7
0
        public async Task DashControllerStatsTest()
        {
            var data    = new HomeApiDataHandler();
            var display = new StatsDisplay
            {
                Tenant   = TenantData.GetFirstDisplay(),
                Meetings = new List <MeetingDisplay>()
                {
                    MeetingData.GetFirstDisplay(false)
                },
                Msgs = new List <MsgDisplay>()
                {
                    MsgData.GetFirstDisplay(false)
                },
            };

            data.Result.Setup(m => m.Execute(It.IsAny <StatsComposite>())).Returns(display);

            var controller = new DashController(data, Logic)
            {
                CurrentUser = StandardUser
            };
            var result = await controller.Stats() as OkObjectResult;

            result.Should().NotBeNull();
            result.Should().BeOfType <OkObjectResult>();
            result.Value.Should().NotBeNull();

            var check = result.Value as StatsViewModel;

            check.Should().NotBeNull();
            check.Meetings.Count().Should().Be(0);
            check.Messages.Count().Should().Be(0);
            check.Success.Should().BeTrue();
            Assert.That(check.Tenant, Is.DeepEqualTo(display.Tenant));

            data.HasExecuted.Should().BeTrue();
            data.Result.Verify(s => s.Execute(It.IsAny <StatsComposite>()), Times.Once());
        }
Пример #8
0
        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);
        }
Пример #9
0
        public async Task UserControllerFilterUnauth()
        {
            var data = new FakeApiDataResultHandler <Tenant, TenantDisplay>();
            var list = new List <TenantDisplay> {
                TenantData.GetFirstDisplay()
            };
            var filter = new TenantFilter {
                TenantRestrict = true
            };

            data.Result.Setup(m => m.Execute(It.IsAny <TenantDisplayByFilter>())).Returns(list);

            var controller = new TenantController(data, Logic)
            {
                CurrentUser = StandardUser
            };
            var result = await controller.Filter(filter) as UnauthorizedResult;

            result.Should().NotBeNull();
            result.Should().BeOfType <UnauthorizedResult>();

            data.HasExecuted.Should().BeFalse();
            data.Result.Verify(s => s.Execute(It.IsAny <TenantDisplayByFilter>()), Times.Never());
        }