Exemplo n.º 1
0
            public async Task Should_map_ReadPartition_and_return_the_expected_ninja()
            {
                // Arrange
                var clanName      = "My clan";
                var entities      = new NinjaEntity[0];
                var expectedNinja = new Ninja[0];

                NinjaEntityTableStorageRepositoryMock
                .Setup(x => x.ReadPartitionAsync(clanName))
                .ReturnsAsync(entities)
                .Verifiable();
                NinjaMappingServiceMock
                .Setup(x => x.Map(entities))
                .Returns(expectedNinja)
                .Verifiable();

                // Act
                var result = await RepositoryUnderTest.ReadAllInClanAsync(clanName);

                // Assert
                NinjaMappingServiceMock
                .Verify(x => x.Map(entities), Times.Once);
                NinjaEntityTableStorageRepositoryMock
                .Verify(x => x.ReadPartitionAsync(clanName), Times.Once);
                Assert.Same(expectedNinja, result);
            }
Exemplo n.º 2
0
            public async Task Should_map_ReadOne_and_return_the_expected_ninja()
            {
                // Arrange
                var clanName      = "My clan";
                var ninjaKey      = "123FB950-57DB-4CD0-B4D1-7E6B00A6163A";
                var entity        = new NinjaEntity();
                var expectedNinja = new Ninja();

                NinjaEntityTableStorageRepositoryMock
                .Setup(x => x.ReadOneAsync(clanName, ninjaKey))
                .ReturnsAsync(entity)
                .Verifiable();
                NinjaMappingServiceMock
                .Setup(x => x.Map(entity))
                .Returns(expectedNinja)
                .Verifiable();

                // Act
                var result = await RepositoryUnderTest.ReadOneAsync(clanName, ninjaKey);

                // Assert
                NinjaMappingServiceMock
                .Verify(x => x.Map(entity), Times.Once);
                NinjaEntityTableStorageRepositoryMock
                .Verify(x => x.ReadOneAsync(clanName, ninjaKey), Times.Once);
                Assert.Same(expectedNinja, result);
            }
Exemplo n.º 3
0
            public async Task Should_map_InsertOrMerge_and_return_the_expected_ninja()
            {
                // Arrange
                var ninjaToUpdate  = new Ninja();
                var entityToUpdate = new NinjaEntity();
                var updatedEntity  = new NinjaEntity();
                var expectedNinja  = new Ninja();

                NinjaMappingServiceMock
                .Setup(x => x.Map(ninjaToUpdate))
                .Returns(entityToUpdate)
                .Verifiable();
                NinjaEntityTableStorageRepositoryMock
                .Setup(x => x.InsertOrMergeAsync(entityToUpdate))
                .ReturnsAsync(updatedEntity)
                .Verifiable();
                NinjaMappingServiceMock
                .Setup(x => x.Map(updatedEntity))
                .Returns(expectedNinja)
                .Verifiable();

                // Act
                var result = await RepositoryUnderTest.UpdateAsync(ninjaToUpdate);

                // Assert
                NinjaMappingServiceMock.Verify(x => x.Map(ninjaToUpdate), Times.Once);
                NinjaEntityTableStorageRepositoryMock.Verify(x => x.InsertOrMergeAsync(entityToUpdate), Times.Once);
                NinjaMappingServiceMock.Verify(x => x.Map(updatedEntity), Times.Once);
                Assert.Same(expectedNinja, result);
            }