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); }
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)); }
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)); }
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)); }
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)); }