Ejemplo n.º 1
0
        public async Task ShouldAddGuardianAttachmentAsync()
        {
            // given
            GuardianAttachment randomGuardianAttachment   = CreateRandomGuardianAttachment();
            GuardianAttachment inputGuardianAttachment    = randomGuardianAttachment;
            GuardianAttachment storageGuardianAttachment  = randomGuardianAttachment;
            GuardianAttachment expectedGuardianAttachment = storageGuardianAttachment;

            this.storageBrokerMock.Setup(broker =>
                                         broker.InsertGuardianAttachmentAsync(inputGuardianAttachment))
            .ReturnsAsync(storageGuardianAttachment);

            // when
            GuardianAttachment actualGuardianAttachment =
                await this.guardianAttachmentService.AddGuardianAttachmentAsync(inputGuardianAttachment);

            // then
            actualGuardianAttachment.Should().BeEquivalentTo(expectedGuardianAttachment);

            this.storageBrokerMock.Verify(broker =>
                                          broker.InsertGuardianAttachmentAsync(inputGuardianAttachment),
                                          Times.Once);

            this.storageBrokerMock.VerifyNoOtherCalls();
            this.storageBrokerMock.VerifyNoOtherCalls();
        }
Ejemplo n.º 2
0
        public async Task ShouldRetrieveGuardianAttachmentById()
        {
            // given
            GuardianAttachment randomGuardianAttachment   = CreateRandomGuardianAttachment();
            GuardianAttachment storageGuardianAttachment  = randomGuardianAttachment;
            GuardianAttachment expectedGuardianAttachment = storageGuardianAttachment;

            this.storageBrokerMock.Setup(broker =>
                                         broker.SelectGuardianAttachmentByIdAsync
                                             (randomGuardianAttachment.GuardianId, randomGuardianAttachment.AttachmentId))
            .Returns(new ValueTask <GuardianAttachment>(randomGuardianAttachment));

            // when
            GuardianAttachment actualGuardianAttachment = await
                                                          this.guardianAttachmentService.RetrieveGuardianAttachmentByIdAsync(
                randomGuardianAttachment.GuardianId, randomGuardianAttachment.AttachmentId);

            // then
            actualGuardianAttachment.Should().BeEquivalentTo(expectedGuardianAttachment);

            this.storageBrokerMock.Verify(broker =>
                                          broker.SelectGuardianAttachmentByIdAsync
                                              (randomGuardianAttachment.GuardianId, randomGuardianAttachment.AttachmentId),
                                          Times.Once);

            this.storageBrokerMock.VerifyNoOtherCalls();
            this.loggingBrokerMock.VerifyNoOtherCalls();
        }
Ejemplo n.º 3
0
        public async Task ShouldRemoveGuardianAttachmentAsync()
        {
            // given
            var                randomGuardianId         = Guid.NewGuid();
            var                randomAttachmentId       = Guid.NewGuid();
            Guid               inputGuardianId          = randomGuardianId;
            Guid               inputAttachmentId        = randomAttachmentId;
            DateTimeOffset     inputDateTime            = GetRandomDateTime();
            GuardianAttachment randomGuardianAttachment = CreateRandomGuardianAttachment(inputDateTime);

            randomGuardianAttachment.GuardianId   = inputGuardianId;
            randomGuardianAttachment.AttachmentId = inputAttachmentId;
            GuardianAttachment storageGuardianAttachment  = randomGuardianAttachment;
            GuardianAttachment expectedGuardianAttachment = storageGuardianAttachment;

            this.storageBrokerMock.Setup(broker =>
                                         broker.SelectGuardianAttachmentByIdAsync(inputGuardianId, inputAttachmentId))
            .ReturnsAsync(storageGuardianAttachment);

            this.storageBrokerMock.Setup(broker =>
                                         broker.DeleteGuardianAttachmentAsync(storageGuardianAttachment))
            .ReturnsAsync(expectedGuardianAttachment);

            // when
            GuardianAttachment actualGuardianAttachment =
                await this.guardianAttachmentService.RemoveGuardianAttachmentByIdAsync(
                    inputGuardianId, inputAttachmentId);

            // then
            actualGuardianAttachment.Should().BeEquivalentTo(expectedGuardianAttachment);

            this.storageBrokerMock.Verify(broker =>
                                          broker.SelectGuardianAttachmentByIdAsync(inputGuardianId, inputAttachmentId),
                                          Times.Once);

            this.storageBrokerMock.Verify(broker =>
                                          broker.DeleteGuardianAttachmentAsync(storageGuardianAttachment),
                                          Times.Once);

            this.storageBrokerMock.VerifyNoOtherCalls();
            this.storageBrokerMock.VerifyNoOtherCalls();
        }