public void Fecha_ShouldReturnDateAfterNException() { //Arrange Mock.Get <ISqlConnectService>(_sqlConnect).SetupSequence(x => x.Execute(It.IsAny <SqlCommand>())) .Throws(SqlExceptionFactory.NewSqlException()) .Throws(SqlExceptionFactory.NewSqlException()) .Throws(SqlExceptionFactory.NewSqlException()) .Throws(SqlExceptionFactory.NewSqlException()) .Throws(SqlExceptionFactory.NewSqlException()) .Throws(SqlExceptionFactory.NewSqlException()) .Throws(SqlExceptionFactory.NewSqlException()) .Returns(10.February(2020)); _sqlDependencyService.CantidadReconecciones = -1; _sqlDependencyService.Timeout = 0; DateTime fecha = new DateTime(); //Act _sqlDependencyService.Start(); fecha = _sqlDependencyService.Fecha; //Assert fecha.Should().Be(10.February(2020)); }
public ExecuteFicture() { _sqlConnect = Mock.Of <ISqlConnectService>(MockBehavior.Default); Mock.Get <ISqlConnectService>(_sqlConnect).SetupSequence(x => x.Execute(It.IsAny <SqlCommand>())) .Returns(new DateTime(2020, 01, 24)) .Returns(new DateTime(2020, 01, 25)) .Throws(SqlExceptionFactory.NewSqlException()) .Returns(new DateTime(2020, 02, 10)); }
public void Fecha_ShouldReturnDateAfterRecargarFecha() { //Arrange bool isCorrect = true; DateTime Fecha = new DateTime(); Mock.Get <ISqlConnectService>(_sqlConnect).SetupSequence(x => x.Execute(It.IsAny <SqlCommand>())) .Returns(new DateTime(2020, 01, 24)) .Returns(new DateTime(2020, 01, 25)) .Throws(SqlExceptionFactory.NewSqlException()) .Returns(new DateTime(2020, 02, 10)) .Returns(new DateTime(2020, 02, 10)); Queue <DateTime> lista = new Queue <DateTime>(); lista.Enqueue(new DateTime(2020, 01, 24)); lista.Enqueue(new DateTime(2020, 01, 25)); lista.Enqueue(new DateTime(2020, 02, 10)); lista.Enqueue(new DateTime(2020, 02, 10)); _sqlDependencyService.CantidadReconecciones = -1; _sqlDependencyService.Timeout = 0; //Act _sqlDependencyService.Start(); for (int i = 4; i > 0; i--) { Fecha = _sqlDependencyService.Fecha; if (Fecha != lista.Dequeue()) { isCorrect = false; break; } _sqlDependencyService.RecargarFecha(); } //Assert isCorrect.Should().BeTrue(); }