public void ValidateOrderId_ReturnsInvalidOrderIdState_WhenOrderId_IsNotCorrectFormat() { //Arrange var mockLogger = new Mock <ILogger <StockIdValidationService> >(); var mockDateTimeWrapper = new Mock <IDateTimeWrapper>(MockBehavior.Strict); mockDateTimeWrapper.Setup(x => x.Now()).Returns(new DateTime()); var sut = new StockIdValidationService(mockDateTimeWrapper.Object, mockLogger.Object); //Act var result = sut.ValidateOrderId(new Guid().ToString(), 0); //Assert Assert.Equal(ValidationState.InvalidOrderId, result); }
public void ValidateOrderId_ReturnsInvalidOrderIdState_WhenOrderIdDate_IsNotEqualToDateTimeNow(DateTime dateTime, int index) { //Arrange var mockLogger = new Mock <ILogger <StockIdValidationService> >(); var mockDateTimeWrapper = new Mock <IDateTimeWrapper>(MockBehavior.Strict); mockDateTimeWrapper.Setup(x => x.Now()).Returns(dateTime.AddDays(1)); var expectedDate = $"{dateTime.Day:00}/{dateTime.Month:00}/{dateTime.Year}"; var orderId = $"QF-{expectedDate}-{index}"; var sut = new StockIdValidationService(mockDateTimeWrapper.Object, mockLogger.Object); //Act var result = sut.ValidateOrderId(orderId, 0); //Assert Assert.Equal(ValidationState.InvalidOrderId, result); }
ValidateOrderId_ReturnsInvalidOrderIdState_WhenOrderId_IsNotEqualToDateTimeNow_AndOrderIdIsLessThanPreviousOrderId( DateTime dateTime, int currentIndex, int previousIndex) { //Arrange var mockLogger = new Mock <ILogger <StockIdValidationService> >(); var mockDateTimeWrapper = new Mock <IDateTimeWrapper>(MockBehavior.Strict); mockDateTimeWrapper.Setup(x => x.Now()).Returns(new DateTime()); var expectedDate = $"{dateTime.Day:00}/{dateTime.Month:00}/{dateTime.Year}"; currentIndex -= previousIndex; var currentOrderId = $"QF-{expectedDate}-{currentIndex}"; var sut = new StockIdValidationService(mockDateTimeWrapper.Object, mockLogger.Object); //Act var result = sut.ValidateOrderId(currentOrderId, previousIndex); //Assert Assert.Equal(ValidationState.InvalidOrderId, result); }