public void CreateInstance_WhenInvokedWithValidParameters() { //Arrange var sportscardFactoryMock = new Mock<ISportscardFactory>(); var sportService = new Mock<ISportService>(); //Act var addSportToSportshallCommand = new AddSportToSportshallCommand(sportscardFactoryMock.Object, sportService.Object); //Assert Assert.IsNotNull(addSportToSportshallCommand); Assert.IsInstanceOfType(addSportToSportshallCommand, typeof(ICommand)); }
public void ThrowArgumentException_WhenInvokedWithEmptyParametersCollection() { // Arrange var sportscardFactoryMock = new Mock <ISportscardFactory>(); var sportServiceMock = new Mock <ISportService>(); var sportName = "Gym"; var sportshallName = "Topfit"; var expectedMessage = $"{sportName} were added to {sportshallName} and added to database."; var addSportToSportshallCommand = new AddSportToSportshallCommand(sportscardFactoryMock.Object, sportServiceMock.Object); var parameters = new List <string>(); //Act && Assert Assert.ThrowsException <ArgumentException>(() => addSportToSportshallCommand.Execute(parameters)); }
public void CallSportToSportshallAddMethodOnce_WhenInvokedWithValidParameters() { // Arrange var sportscardFactoryMock = new Mock <ISportscardFactory>(); var sportServiceMock = new Mock <ISportService>(); var sportName = "Gym"; var sportshallName = "Topfit"; var addSportToSportshallCommand = new AddSportToSportshallCommand(sportscardFactoryMock.Object, sportServiceMock.Object); var parameters = new List <string>() { sportName, sportshallName }; //Act addSportToSportshallCommand.Execute(parameters); //Assert sportServiceMock.Verify(x => x.AddSportToSportshall(sportName, sportshallName), Times.Once); }
public void ReturnSuccessMessage_WhenInvokedWithValidParameters() { // Arrange var sportscardFactoryMock = new Mock <ISportscardFactory>(); var sportServiceMock = new Mock <ISportService>(); var sportName = "Gym"; var sportshallName = "Topfit"; var expectedMessage = $"{sportName} was added to {sportshallName} and added to database."; var addSportToSportshallCommand = new AddSportToSportshallCommand(sportscardFactoryMock.Object, sportServiceMock.Object); var parameters = new List <string>() { sportName, sportshallName }; //Act var actualMessage = addSportToSportshallCommand.Execute(parameters); //Assert Assert.AreEqual(expectedMessage, actualMessage); }