Exemplo n.º 1
0
        public async void CreateOneAsync_ReturnsNull_WhenRepositoryReturnsNull()
        {
            // Arrange
            var muscleToCreate = TestData.Muscles.MuscleWithoutId;

            MusclesRepositoryMock
            .Setup(x => x.CreateOneAsync(It.IsAny <Muscle>()))
            .ReturnsAsync((Muscle)null);

            // Act
            var result = await MusclesService.CreateOneAsync(muscleToCreate);

            // Assert
            Assert.Null(result);
        }
Exemplo n.º 2
0
        public async void CreateOneAsync_ReturnsCreatedMuscle_WhenServiceReturnsMuscle()
        {
            // Arrange
            var muscleToCreate = TestData.Muscles.MuscleWithoutId;
            var createdMuscle  = TestData.Muscles.MuscleWithoutId;

            createdMuscle.Id = "1234";
            MusclesRepositoryMock
            .Setup(x => x.CreateOneAsync(It.IsAny <Muscle>()))
            .ReturnsAsync(createdMuscle);

            // Act
            var result = await MusclesService.CreateOneAsync(muscleToCreate);

            // Assert
            Assert.Same(createdMuscle, result);
        }