Beispiel #1
0
        public async Task MeetingControllerPostAdd()
        {
            var data       = new MeetingApiDataHandler();
            var model      = MeetingData.GetFirst();
            var attendance = new List <Attendance>()
            {
                AttendanceData.GetFirst(), AttendanceData.GetSecond()
            };
            var users = new List <User>()
            {
                UserData.GetFirst(), UserData.GetSecond()
            };

            data.Result.Setup(m => m.Execute(It.IsAny <Persist <Meeting> >())).Returns(model);
            data.Result.Setup(m => m.Execute(It.IsAny <Loaders <Attendance> >())).Returns(attendance);
            data.Result.Setup(m => m.Execute(It.IsAny <Loaders <User> >())).Returns(users);

            var controller = new MeetingController(data, new LogicHandler()
            {
                DataHandler = data
            })
            {
                CurrentUser = AdminUser
            };
            var viewModel = controller.Mapper.Map <MeetingViewModel>(model);

            viewModel.Id        = string.Empty;
            viewModel.Attendees = new List <ResultProfile>()
            {
                UserData.GetFirstProfile(), UserData.GetSecondProfile()
            };

            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.Identity.Should().Be(model.Id);

            data.HasExecuted.Should().BeTrue();
            data.HasCommitted.Should().BeTrue();
            data.Result.Verify(s => s.Execute(It.IsAny <Loader <Meeting> >()), Times.Never);
            data.Result.Verify(s => s.Execute(It.IsAny <Persist <Meeting> >()), Times.Once());
        }
Beispiel #2
0
        protected override void SetupDatabase(IDocumentStore store)
        {
            store.ExecuteIndex(new AttendanceIndex());
            store.ExecuteIndex(new FavFanIndex());

            using (var session = store.OpenSession())
            {
                session.Store(AttendanceData.GetFirst());
                session.Store(AttendanceData.GetSecond());
                session.Store(MeetingData.GetFirst());
                session.Store(UserData.GetFirst());
                session.Store(UserData.GetSecond());
                session.SaveChanges();
            }

            WaitForIndexing(store);
        }
Beispiel #3
0
        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 AttendanceControllerGetUnauthorised()
        {
            var data  = new AttendanceApiDataHandler();
            var model = AttendanceData.GetFirst();

            data.Result.Setup(m => m.Execute(It.IsAny <Loader <Attendance> >())).Returns(model);

            var controller = new AttendanceController(data, Logic)
            {
                CurrentUser = NonTenantUser
            };
            var result = await controller.Get(AttendanceData.FirstId) as UnauthorizedResult;

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

            data.HasExecuted.Should().BeTrue();
            data.Result.Verify(s => s.Execute(It.IsAny <Loader <Attendance> >()), Times.Once());
        }
        public async Task AttendanceControllerNoShow()
        {
            var data    = new AttendanceApiDataHandler();
            var confirm = ModelConfirm <Attendance> .CreateSuccess(AttendanceData.GetFirst());

            data.Result.Setup(m => m.Execute(It.IsAny <AttendanceNoShow>())).Returns(true);

            data.ResultConfirm = confirm;

            var controller = new AttendanceController(data, Logic)
            {
                CurrentUser = AdminUser
            };
            var result = await controller.NoShow(MeetingData.FirstId, StandardUser.Id) as OkObjectResult;

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

            data.HasExecuted.Should().BeTrue();
            data.HasCommitted.Should().BeTrue();
            data.Result.Verify(s => s.Execute(It.IsAny <AttendanceNoShow>()), Times.Once);
        }
        public async Task AttendanceControllerPostUnauthorised()
        {
            var data  = new AttendanceApiDataHandler();
            var model = AttendanceData.GetFirst();

            data.Result.Setup(m => m.Execute(It.IsAny <Loader <Attendance> >())).Returns(model);
            data.Result.Setup(m => m.Execute(It.IsAny <Persist <Attendance> >())).Returns(model);

            var controller = new AttendanceController(data, Logic)
            {
                CurrentUser = NonTenantUser
            };
            var viewModel = controller.Mapper.Map <AttendanceViewModel>(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 <Loader <Attendance> >()), Times.AtLeastOnce);
            data.Result.Verify(s => s.Execute(It.IsAny <Persist <Attendance> >()), Times.Never);
        }
Beispiel #7
0
        public async Task MeetingControllerCloseNotDone()
        {
            var data  = new MeetingApiDataHandler();
            var logic = new InteractApiLogicHandler();

            data.Result.Setup(m => m.Execute(It.IsAny <MeetingById>())).Returns(MeetingData.GetFirst());
            data.Result.Setup(m => m.Execute(It.IsAny <Persist <Meeting> >())).Returns(MeetingData.GetSecond());

            var attendance = AttendanceData.GetFirst();

            attendance.HasAttended = false;

            data.ResultAttendances = new List <Attendance>()
            {
                attendance
            };

            var controller = new MeetingController(data, logic)
            {
                CurrentUser = StandardUser
            };
            var result = await controller.Close(MeetingData.FirstId) as OkObjectResult;

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

            var check = result.Value as ConfirmViewModel;

            check.Success.Should().BeFalse();

            data.HasExecuted.Should().BeTrue();
            data.HasCommitted.Should().BeFalse();
            data.Result.Verify(s => s.Execute(It.IsAny <MeetingById>()), Times.Once);
            data.Result.Verify(s => s.Execute(It.IsAny <Persist <Meeting> >()), Times.Never());
        }