Ejemplo n.º 1
0
        public void Execute_Should_Call_Deserialize_Once()
        {
            // Arrange
            this.importerStub.Setup(x => x.Import(It.IsAny <string>())).Returns("json");
            this.deserializerStub.Setup(x => x.Deserialize(It.IsAny <string>())).Returns(new List <Employee>()
            {
                new Employee()
                {
                    FirstName = "Test", LastName = "Test", Email = "*****@*****.**", PhoneNumber = "0891234512"
                }
            });

            var JSONImportEmployeesMock = new JSONImportEmployees(this.dbStub, this.deserializerStub.Object, this.importerStub.Object, this.writerStub.Object);

            var parameters = new List <string>()
            {
                "JSONImportEmployees"
            };

            // Act
            JSONImportEmployeesMock.Execute(parameters);

            // Assert
            this.deserializerStub.Verify(x => x.Deserialize(It.IsAny <string>()), Times.Once);
        }
Ejemplo n.º 2
0
        public void Execute_Should_Throw_ArgumentNullException_When_Parameters_IsNull()
        {
            // Arrange
            var JSONImportEmployeesMock = new JSONImportEmployees(this.dbStub, this.deserializerStub.Object, this.importerStub.Object, this.writerStub.Object);

            // Act && Assert
            Assert.ThrowsException <ArgumentNullException>(() => JSONImportEmployeesMock.Execute(null));
        }
Ejemplo n.º 3
0
        public void Execute_Should_Throw_ArgumentNullException_When_Command_IsNull()
        {
            // Arrange
            var JSONImportEmployeesMock = new JSONImportEmployees(this.dbStub, this.deserializerStub.Object, this.importerStub.Object, this.writerStub.Object);

            var parameters = new List <string>()
            {
                null,
                "all"
            };

            // Act && Assert
            Assert.ThrowsException <ArgumentNullException>(() => JSONImportEmployeesMock.Execute(parameters));
        }
Ejemplo n.º 4
0
        public void Execute_Should_Throw_ArgumentNullException_When_ParameterCount_IsNotValid()
        {
            // Arrange
            var JSONImportEmployeesMock = new JSONImportEmployees(this.dbStub, this.deserializerStub.Object, this.importerStub.Object, this.writerStub.Object);

            var parameters = new List <string>()
            {
                "JSONImportEmployees",
                "unnecessary argument"
            };

            // Act && Assert
            Assert.ThrowsException <ArgumentNullException>(() => JSONImportEmployeesMock.Execute(parameters));
        }
Ejemplo n.º 5
0
        public void Execute_Should_Thrown_ArgumentException_When_ThereAreNoEmployees()
        {
            // Arrange
            this.importerStub.Setup(x => x.Import(It.IsAny <string>())).Returns("json");
            this.deserializerStub.Setup(x => x.Deserialize(It.IsAny <string>())).Returns(new List <Employee>());

            var JSONImportEmployeesMock = new JSONImportEmployees(this.dbStub, this.deserializerStub.Object, this.importerStub.Object, this.writerStub.Object);

            var parameters = new List <string>()
            {
                "JSONImportEmployees"
            };

            // Act && Assert
            Assert.ThrowsException <ArgumentException>(() => JSONImportEmployeesMock.Execute(parameters));
        }