public async Task ShouldRetrieveCalendarEntryAttachmentById()
        {
            // given
            CalendarEntryAttachment randomCalendarEntryAttachment   = CreateRandomCalendarEntryAttachment();
            CalendarEntryAttachment storageCalendarEntryAttachment  = randomCalendarEntryAttachment;
            CalendarEntryAttachment expectedCalendarEntryAttachment = storageCalendarEntryAttachment;

            this.storageBrokerMock.Setup(broker =>
                                         broker.SelectCalendarEntryAttachmentByIdAsync(
                                             randomCalendarEntryAttachment.CalendarEntryId, randomCalendarEntryAttachment.AttachmentId))
            .ReturnsAsync(randomCalendarEntryAttachment);

            // when
            CalendarEntryAttachment actualCalendarEntryAttachment = await
                                                                    this.calendarEntryAttachmentService.RetrieveCalendarEntryAttachmentByIdAsync(
                randomCalendarEntryAttachment.CalendarEntryId, randomCalendarEntryAttachment.AttachmentId);

            // then
            actualCalendarEntryAttachment.Should().BeEquivalentTo(expectedCalendarEntryAttachment);

            this.storageBrokerMock.Verify(broker =>
                                          broker.SelectCalendarEntryAttachmentByIdAsync(
                                              randomCalendarEntryAttachment.CalendarEntryId, randomCalendarEntryAttachment.AttachmentId),
                                          Times.Once);

            this.storageBrokerMock.VerifyNoOtherCalls();
            this.loggingBrokerMock.VerifyNoOtherCalls();
        }
        public async Task ShouldAddCalendarEntryAttachmentAsync()
        {
            // given
            CalendarEntryAttachment randomCalendarEntryAttachment   = CreateRandomCalendarEntryAttachment();
            CalendarEntryAttachment inputCalendarEntryAttachment    = randomCalendarEntryAttachment;
            CalendarEntryAttachment storageCalendarEntryAttachment  = randomCalendarEntryAttachment;
            CalendarEntryAttachment expectedCalendarEntryAttachment = storageCalendarEntryAttachment;

            this.storageBrokerMock.Setup(broker =>
                                         broker.InsertCalendarEntryAttachmentAsync(inputCalendarEntryAttachment))
            .ReturnsAsync(storageCalendarEntryAttachment);

            // when
            CalendarEntryAttachment actualCalendarEntryAttachment =
                await this.calendarEntryAttachmentService.AddCalendarEntryAttachmentAsync(inputCalendarEntryAttachment);

            // then
            actualCalendarEntryAttachment.Should().BeEquivalentTo(expectedCalendarEntryAttachment);

            this.storageBrokerMock.Verify(broker =>
                                          broker.InsertCalendarEntryAttachmentAsync(inputCalendarEntryAttachment),
                                          Times.Once);

            this.storageBrokerMock.VerifyNoOtherCalls();
            this.loggingBrokerMock.VerifyNoOtherCalls();
            this.dateTimeBrokerMock.VerifyNoOtherCalls();
        }
示例#3
0
        public async Task ShouldGetAllCalendarEntryAttachmentsAsync()
        {
            // given
            var randomCalendarEntryAttachments = new List <CalendarEntryAttachment>();

            for (var i = 0; i <= GetRandomNumber(); i++)
            {
                CalendarEntryAttachment randomCalendarEntryAttachment = await PostCalendarEntryAttachmentAsync();

                randomCalendarEntryAttachments.Add(randomCalendarEntryAttachment);
            }

            List <CalendarEntryAttachment> inputCalendarEntryAttachments    = randomCalendarEntryAttachments;
            List <CalendarEntryAttachment> expectedCalendarEntryAttachments = inputCalendarEntryAttachments;

            // when
            List <CalendarEntryAttachment> actualCalendarEntryAttachments =
                await this.otripleSApiBroker.GetAllCalendarEntryAttachmentsAsync();

            // then
            foreach (CalendarEntryAttachment expectedCalendarEntryAttachment in expectedCalendarEntryAttachments)
            {
                CalendarEntryAttachment actualCalendarEntryAttachment =
                    actualCalendarEntryAttachments.Single(studentAttachment =>
                                                          studentAttachment.CalendarEntryId == expectedCalendarEntryAttachment.CalendarEntryId);

                actualCalendarEntryAttachment.Should().BeEquivalentTo(expectedCalendarEntryAttachment);

                await DeleteCalendarEntryAttachmentAsync(actualCalendarEntryAttachment);
            }
        }
        public async Task ShouldRemoveCalendarEntryAttachmentAsync()
        {
            // given
            var  randomCalendarEntryId = Guid.NewGuid();
            var  randomAttachmentId    = Guid.NewGuid();
            Guid inputCalendarEntryId  = randomCalendarEntryId;
            Guid inputAttachmentId     = randomAttachmentId;
            CalendarEntryAttachment randomCalendarEntryAttachment = CreateRandomCalendarEntryAttachment();

            randomCalendarEntryAttachment.CalendarEntryId = inputCalendarEntryId;
            randomCalendarEntryAttachment.AttachmentId    = inputAttachmentId;
            CalendarEntryAttachment storageCalendarEntryAttachment  = randomCalendarEntryAttachment;
            CalendarEntryAttachment expectedCalendarEntryAttachment = storageCalendarEntryAttachment;

            this.storageBrokerMock.Setup(broker =>
                                         broker.SelectCalendarEntryAttachmentByIdAsync(inputCalendarEntryId, inputAttachmentId))
            .ReturnsAsync(storageCalendarEntryAttachment);

            this.storageBrokerMock.Setup(broker =>
                                         broker.DeleteCalendarEntryAttachmentAsync(storageCalendarEntryAttachment))
            .ReturnsAsync(expectedCalendarEntryAttachment);

            // when
            CalendarEntryAttachment actualCalendarEntryAttachment =
                await this.calendarEntryAttachmentService.RemoveCalendarEntryAttachmentByIdAsync(
                    inputCalendarEntryId, inputAttachmentId);

            // then
            actualCalendarEntryAttachment.Should().BeEquivalentTo(expectedCalendarEntryAttachment);

            this.storageBrokerMock.Verify(broker =>
                                          broker.SelectCalendarEntryAttachmentByIdAsync(inputCalendarEntryId, inputAttachmentId),
                                          Times.Once);

            this.storageBrokerMock.Verify(broker =>
                                          broker.DeleteCalendarEntryAttachmentAsync(storageCalendarEntryAttachment),
                                          Times.Once);

            this.storageBrokerMock.VerifyNoOtherCalls();
            this.loggingBrokerMock.VerifyNoOtherCalls();
            this.dateTimeBrokerMock.VerifyNoOtherCalls();
        }
示例#5
0
        public async Task ShouldPostCalendarEntryAttachmentAsync()
        {
            // given
            CalendarEntryAttachment randomCalendarEntryAttachment = await CreateRandomCalendarEntryAttachment();

            CalendarEntryAttachment inputCalendarEntryAttachment    = randomCalendarEntryAttachment;
            CalendarEntryAttachment expectedCalendarEntryAttachment = inputCalendarEntryAttachment;

            // when
            CalendarEntryAttachment actualCalendarEntryAttachment =
                await this.otripleSApiBroker.PostCalendarEntryAttachmentAsync(inputCalendarEntryAttachment);

            CalendarEntryAttachment retrievedCalendarEntryAttachment =
                await this.otripleSApiBroker.GetCalendarEntryAttachmentByIdsAsync(
                    inputCalendarEntryAttachment.CalendarEntryId,
                    inputCalendarEntryAttachment.AttachmentId);

            // then
            actualCalendarEntryAttachment.Should().BeEquivalentTo(expectedCalendarEntryAttachment);
            retrievedCalendarEntryAttachment.Should().BeEquivalentTo(expectedCalendarEntryAttachment);
            await DeleteCalendarEntryAttachmentAsync(actualCalendarEntryAttachment);
        }
示例#6
0
        public async Task ShouldDeleteCalendarEntryAttachmentAsync()
        {
            // given
            CalendarEntryAttachment randomCalendarEntryAttachment = await PostCalendarEntryAttachmentAsync();

            CalendarEntryAttachment inputCalendarEntryAttachment    = randomCalendarEntryAttachment;
            CalendarEntryAttachment expectedCalendarEntryAttachment = inputCalendarEntryAttachment;

            // when
            CalendarEntryAttachment deletedCalendarEntryAttachment =
                await DeleteCalendarEntryAttachmentAsync(inputCalendarEntryAttachment);

            ValueTask <CalendarEntryAttachment> getCalendarEntryAttachmentByIdTask =
                this.otripleSApiBroker.GetCalendarEntryAttachmentByIdsAsync(
                    inputCalendarEntryAttachment.CalendarEntryId,
                    inputCalendarEntryAttachment.AttachmentId);

            // then
            deletedCalendarEntryAttachment.Should().BeEquivalentTo(expectedCalendarEntryAttachment);

            await Assert.ThrowsAsync <HttpResponseNotFoundException>(() =>
                                                                     getCalendarEntryAttachmentByIdTask.AsTask());
        }