Example #1
0
        public void CreateInstance_WhenInvokedWithValidParameters()
        {
            //Arrange
            var sportscardFactoryMock = new Mock <ISportscardFactory>();
            var visiServiceMock       = new Mock <IVisitService>();

            //Act
            var deleteVisitCommand = new DeleteVisitCommand(sportscardFactoryMock.Object, visiServiceMock.Object);

            //Assert
            Assert.IsNotNull(deleteVisitCommand);
            Assert.IsInstanceOfType(deleteVisitCommand, typeof(ICommand));
        }
        public void ThrowArgumentException_WhenInvokedWithEmptyParametersCollection()
        {
            // Arrange
            var sportscardFactoryMock = new Mock <ISportscardFactory>();
            var visitServiceMock      = new Mock <IVisitService>();

            //var id = "db97a0eb-9411-4f1d-9ead-3997e6271324";
            var expectedMessage = $"The following visit was deleted from database.";

            var deleteVisitCommand = new DeleteVisitCommand(sportscardFactoryMock.Object, visitServiceMock.Object);
            var parameters         = new List <string>();

            //Act && Assert
            Assert.ThrowsException <ArgumentException>(() => deleteVisitCommand.Execute(parameters));
        }
        public void CallCompanyDeleteMethodOnce_WhenInvokedWithValidParameters()
        {
            // Arrange
            var sportscardFactoryMock = new Mock <ISportscardFactory>();
            var visitServiceMock      = new Mock <IVisitService>();

            var id = "db97a0eb-9411-4f1d-9ead-3997e6271324";

            var deleteVisitCommand = new DeleteVisitCommand(sportscardFactoryMock.Object, visitServiceMock.Object);
            var parameters         = new List <string>()
            {
                id
            };

            //Act
            deleteVisitCommand.Execute(parameters);

            //Assert
            visitServiceMock.Verify(x => x.DeleteVisit(new Guid(id)), Times.Once);
        }
        public void ReturnSuccessMessage_WhenInvokedWithValidParameters()
        {
            // Arrange
            var sportscardFactoryMock = new Mock <ISportscardFactory>();
            var visitServiceMock      = new Mock <IVisitService>();

            var id = "db97a0eb-9411-4f1d-9ead-3997e6271324";
            var expectedMessage = $"The following visit was deleted from database.";

            var deleteVisitCommand = new DeleteVisitCommand(sportscardFactoryMock.Object, visitServiceMock.Object);
            var parameters         = new List <string>()
            {
                id
            };

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

            //Assert
            Assert.AreEqual(expectedMessage, actualMessage);
        }