Exemplo n.º 1
0
        public async Task CompleteAddAudioNote_ReturnsAudioNotUploaded()
        {
            // arrange
            var service = new AudioService(new FakeBlobRepository(), new Mock <IAudioTranscriptionService>().Object, new Mock <IEventGridPublisherService>().Object);

            // act
            var result = await service.CompleteAddAudioNoteAsync("fakeid", "fakeuserid", "fakecategory");

            // assert
            Assert.Equal(CompleteAddAudioNoteResult.AudioNotUploaded, result);
        }
Exemplo n.º 2
0
        public async Task CompleteAddAudioNote_ReturnsSuccess()
        {
            // arrange
            var fakeBlobRepository = new FakeBlobRepository();

            fakeBlobRepository.AddFakeBlob(AudioService.AudioBlobContainerName, "fakeuserid/fakeid");
            var service = new AudioService(fakeBlobRepository, new Mock <IAudioTranscriptionService>().Object, new Mock <IEventGridPublisherService>().Object);

            // act
            var result = await service.CompleteAddAudioNoteAsync("fakeid", "fakeuserid", "fakecategory");

            // assert
            Assert.Equal(CompleteAddAudioNoteResult.Success, result);
        }
Exemplo n.º 3
0
        public async Task CompleteAddAudioNote_UpdatesBlobMetadata()
        {
            // arrange
            var fakeBlobRepository = new FakeBlobRepository();

            fakeBlobRepository.AddFakeBlob(AudioService.AudioBlobContainerName, "fakeuserid/fakeid");
            var service = new AudioService(fakeBlobRepository, new Mock <IAudioTranscriptionService>().Object, new Mock <IEventGridPublisherService>().Object);

            // act
            await service.CompleteAddAudioNoteAsync("fakeid", "fakeuserid", "fakecategory");

            // assert
            Assert.Equal("fakecategory", fakeBlobRepository.Blobs.Single().Blob.Metadata[AudioService.CategoryIdMetadataName]);
            Assert.Equal("fakeuserid", fakeBlobRepository.Blobs.Single().Blob.Metadata[AudioService.UserIdMetadataName]);
        }
Exemplo n.º 4
0
        public async Task CompleteAddAudioNote_ReturnsAudioAlreadyCreated()
        {
            // arrange
            var fakeBlobRepository = new FakeBlobRepository();
            var blob = new CloudBlockBlob(new Uri("https://fakeblobrepository/audio/fakeuserid/fakeid"));

            blob.Metadata.Add(AudioService.CategoryIdMetadataName, "fakecategory");
            blob.Metadata.Add(AudioService.UserIdMetadataName, "fakeuserid");
            fakeBlobRepository.AddFakeBlob(AudioService.AudioBlobContainerName, "fakeuserid/fakeid", blob);
            var mockEventGridPublisherService = new Mock <IEventGridPublisherService>();
            var service = new AudioService(fakeBlobRepository, new Mock <IAudioTranscriptionService>().Object, mockEventGridPublisherService.Object);

            // act
            var result = await service.CompleteAddAudioNoteAsync("fakeid", "fakeuserid", "fakecategory");

            // assert
            Assert.Equal(CompleteAddAudioNoteResult.AudioAlreadyCreated, result);
        }
Exemplo n.º 5
0
        public async Task CompleteAddAudioNote_PublishesAudioCreatedEventToEventGrid()
        {
            // arrange
            var fakeBlobRepository = new FakeBlobRepository();

            fakeBlobRepository.AddFakeBlob(AudioService.AudioBlobContainerName, "fakeuserid/fakeid");
            var mockEventGridPublisherService = new Mock <IEventGridPublisherService>();
            var service = new AudioService(fakeBlobRepository, new Mock <IAudioTranscriptionService>().Object, mockEventGridPublisherService.Object);

            // act
            await service.CompleteAddAudioNoteAsync("fakeid", "fakeuserid", "fakecategory");

            // assert
            mockEventGridPublisherService.Verify(m =>
                                                 m.PostEventGridEventAsync(EventTypes.Audio.AudioCreated,
                                                                           "fakeuserid/fakeid",
                                                                           It.Is <AudioCreatedEventData>(d => d.Category == "fakecategory")),
                                                 Times.Once);
        }