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

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

                // Act
                var result = await RepositoryUnderTest.ReadAllAsync();

                // Assert
                NinjaMappingServiceMock
                .Verify(x => x.Map(entities), Times.Once);
                NinjaEntityTableStorageRepositoryMock
                .Verify(x => x.ReadAllAsync(), Times.Once);
                Assert.Same(expectedNinja, result);
            }
            public async void Should()
            {
                // Arrange
                await RepositoryUnderTest.InsertOrReplaceAsync(new SomeTestEntity
                {
                    PartitionKey = "Partition1",
                    RowKey       = "Key1"
                });

                await RepositoryUnderTest.InsertOrReplaceAsync(new SomeTestEntity
                {
                    PartitionKey = "Partition1",
                    RowKey       = "Key2"
                });

                await RepositoryUnderTest.InsertOrReplaceAsync(new SomeTestEntity
                {
                    PartitionKey = "Partition2",
                    RowKey       = "Key1"
                });

                // Act
                var result = await RepositoryUnderTest.ReadAllAsync();

                // Assert
                Assert.NotNull(result);
                Assert.Equal(3, result.Count());
            }
            public async Task ReadAllAsync_Returns_Workouts()
            {
                // Arrange
                var expectedWorkouts = new[]
                {
                    new Workout {
                        Name = "Test workout 01"
                    },
                    new Workout {
                        Name = "Test workout 02"
                    },
                    new Workout {
                        Name = "Test workout 03"
                    }
                };

                TrainingPlanContextMock.Workouts.AddRange(expectedWorkouts);
                await TrainingPlanContextMock.SaveChangesAsync();

                // Act
                var result = await RepositoryUnderTest.ReadAllAsync();

                // Assert
                Assert.Collection(result,
                                  workout => Assert.Same(expectedWorkouts[0], workout),
                                  workout => Assert.Same(expectedWorkouts[1], workout),
                                  workout => Assert.Same(expectedWorkouts[2], workout)
                                  );
            }
Exemplo n.º 4
0
            public async Task Should_return_all_clans()
            {
                // Act
                var result = await RepositoryUnderTest.ReadAllAsync();

                // Assert
                Assert.Collection(result,
                                  clan => Assert.Same(Clans[0], clan),
                                  clan => Assert.Same(Clans[1], clan),
                                  clan => Assert.Same(Clans[2], clan)
                                  );
            }