public void ReturnSuccessMessage_WhenInvokedWithValidParameters()
        {
            // Arrange
            var sportscardFactoryMock = new Mock <ISportscardFactory>();
            var sportshallServiceMock = new Mock <ISportshallService>();

            var sportshallName     = "Topfit";
            var expectedMessage    = $"{sportshallName} sportshall was added to database.";
            var expectedSportshall = new SportshallDto()
            {
                Name = sportshallName
            };

            sportscardFactoryMock
            .Setup(x => x.CreateSportshallDto(sportshallName))
            .Returns(expectedSportshall);

            var addSportshallCommand = new AddSportshallCommand(sportscardFactoryMock.Object, sportshallServiceMock.Object);
            var parameters           = new List <string>()
            {
                sportshallName
            };

            //Act
            var actualMessage = addSportshallCommand.Execute(parameters);

            //Assert
            Assert.AreEqual(expectedMessage, actualMessage);
        }
        public void ThrowArgumentNullException_WhenInvokedWithInvalidNullSportshallNameParameter()
        {
            // Arrange
            var sportscardFactoryMock = new Mock <ISportscardFactory>();
            var sportshallServiceMock = new Mock <ISportshallService>();

            var sportshallName     = "Topfit";
            var expectedMessage    = $"{sportshallName} sportshall was added to database.";
            var expectedSportshall = new SportshallDto()
            {
                Name = sportshallName
            };

            sportscardFactoryMock
            .Setup(x => x.CreateSportshallDto(sportshallName))
            .Returns(expectedSportshall);

            var addSportshallCommand = new AddSportshallCommand(sportscardFactoryMock.Object, sportshallServiceMock.Object);
            var parameters           = new List <string>()
            {
                null
            };

            //Act && Assert
            Assert.ThrowsException <ArgumentNullException>(() => addSportshallCommand.Execute(parameters));
        }
        public void CallSportshallAddMethodOnce_WhenInvokedWithValidParameters()
        {
            // Arrange
            var sportscardFactoryMock = new Mock <ISportscardFactory>();
            var sportshallServiceMock = new Mock <ISportshallService>();

            var sportshallName     = "Topfit";
            var expectedSportshall = new SportshallDto()
            {
                Name = sportshallName
            };

            sportscardFactoryMock
            .Setup(x => x.CreateSportshallDto(sportshallName))
            .Returns(expectedSportshall);

            var addSportshallCommand = new AddSportshallCommand(sportscardFactoryMock.Object, sportshallServiceMock.Object);
            var parameters           = new List <string>()
            {
                sportshallName
            };

            //Act
            addSportshallCommand.Execute(parameters);

            //Assert
            sportshallServiceMock.Verify(x => x.AddSportshall(expectedSportshall), Times.Once);
        }