public void ConvertsDateFilterParametersToUTC()
            {
                // Arrange
                var productionDateStart = DateTime.Now.AddDays(-5);
                var productionDateEnd   = DateTime.Now;
                var expectedStart       = productionDateStart.ToUniversalTime();
                var expectedEnd         = productionDateEnd.ToUniversalTime();

                if (productionDateStart == expectedStart || productionDateEnd == expectedEnd)
                {
                    Assert.Inconclusive("Production dates are already in UTC");
                }

                FilterLotParameters actualParameters = null;

                MockLotService
                .Setup(m => m.GetLotSummaries(It.IsAny <FilterLotParameters>()))
                .Callback((FilterLotParameters param) => actualParameters = param)
                .Returns(new SuccessResult <ILotQualitySummariesReturn>(Fixture.Create <ILotQualitySummariesReturn>()));

                // Act
                LotsControler.Get(productionStart: productionDateStart, productionEnd: productionDateEnd);

                // Assert
                Assert.IsNotNull(actualParameters);
                Assert.AreEqual(expectedStart, actualParameters.ProductionStartRangeStart);
                Assert.AreEqual(expectedEnd, actualParameters.ProductionStartRangeEnd);
            }
            public new void SetUp()
            {
                base.SetUp();
                MockLotService.Setup(m => m.SetLotAttributes(It.IsAny <ISetLotAttributeParameters>()))
                .Returns(new SuccessResult <ILotStatInfoReturn>());

                _values = Fixture.Create <UpdateLotRequest>();
            }
            public new void SetUp()
            {
                base.SetUp();
                _expectedResult = Fixture.Create <ILotQualitySingleSummaryReturn>();

                MockLotService
                .Setup(m => m.GetLotSummary(Key))
                .Returns(new SuccessResult <ILotQualitySingleSummaryReturn>(_expectedResult));

                AutoMapperConfiguration.Configure();
            }
            public async Task Returns500OnFailure()
            {
                // Arrange
                const string message = "an error occurred";

                MockLotService.Setup(m => m.SetLotAttributes(It.IsAny <ISetLotAttributeParameters>()))
                .Returns(new FailureResult <ILotStatInfoReturn>(null, message));

                // Act
                var result = await LotsControler.Put(LotKey, _values);

                // Assert
                Assert.AreEqual(HttpStatusCode.InternalServerError, result.StatusCode);
                Assert.AreEqual(message, result.ReasonPhrase);
            }
            public async Task Returns400OnInvalid()
            {
                // Arrange
                const string message = "invalid stuff happened";

                MockLotService.Setup(m => m.SetLotAttributes(It.IsAny <ISetLotAttributeParameters>()))
                .Returns(new InvalidResult <ILotStatInfoReturn>(null, message));

                // Act
                var result = await LotsControler.Put(LotKey, _values);

                // Assert
                Assert.AreEqual(HttpStatusCode.BadRequest, result.StatusCode);
                Assert.AreEqual(message, result.ReasonPhrase);
            }
            public async Task GetByKeyWithIntegratedProjector()
            {
                // Arrange
                const string lotKey         = "12345";
                var          expectedResult = Fixture.Create <ILotQualitySingleSummaryReturn>();

                MockLotService
                .Setup(m => m.GetLotSummary(lotKey))
                .Returns(new SuccessResult <ILotQualitySingleSummaryReturn>(expectedResult));

                // Act
                var result = await SystemUnderTest.Get(lotKey);

                // Assert
                Assert.IsNotNull(result);
                Assert.AreEqual(expectedResult.AttributeNamesByProductType, result.AttributeNamesByProductType);
            }
            public void ParametersAreCorrectlyTranslatedToDto()
            {
                // Arrange
                ISetLotAttributeParameters actualParameters = null;

                MockLotService.Setup(m => m.SetLotAttributes(It.IsAny <ISetLotAttributeParameters>()))
                .Callback((ISetLotAttributeParameters p) => actualParameters = p)
                .Returns(new SuccessResult <ILotStatInfoReturn>());

                // Act
                LotsControler.Put(LotKey, _values);

                // Assert
                Assert.IsNotNull(actualParameters);
                Assert.AreEqual(LotKey, actualParameters.LotKey);
                Assert.AreEqual(((ISetLotAttributeParameters)_values).Attributes, actualParameters.Attributes);
            }
            public void Returns200OnSuccess()
            {
                // arrange
                MockLotService.Setup(m => m.SetLotQualityStatus(It.IsAny <ISetLotStatusParameters>()))
                .Returns(new SuccessResult <ILotStatInfoReturn>());
                const string           lotKey         = "12345";
                const LotQualityStatus expectedStatus = LotQualityStatus.Released;
                var dto = new SetLotStatusDto
                {
                    Status = expectedStatus
                };

                // act
                var response = LotsControler.SetStatus(lotKey, dto);

                // assert
                Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
            }
Esempio n. 9
0
            public void CallsSetLotHoldStatusServiceMethodAsExpected()
            {
                // arrange
                const string expectedLotKey = "04 14 001 01";
                var          holdParameters = Fixture.Create <LotHoldDto>();
                ISetLotHoldStatusParameters actualParameters = null;

                MockLotService.Setup(m => m.SetLotHoldStatus(It.IsAny <ISetLotHoldStatusParameters>()))
                .Callback((ISetLotHoldStatusParameters p) => { actualParameters = p; })
                .Returns(new SuccessResult <ILotStatInfoReturn>());

                // act
                SystemUnderTest.Put(expectedLotKey, holdParameters);

                // assert
                MockLotService.Verify(m => m.SetLotHoldStatus(It.IsAny <ISetLotHoldStatusParameters>()), Times.Once());
                Assert.AreEqual(expectedLotKey, actualParameters.LotKey);
                Assert.AreEqual(holdParameters, actualParameters.Hold);
            }
            public void GetManyWithIntegratedProjector()
            {
                // Arrange
                var testFixture = new GetMany();

                testFixture.SetUp();

                var expectedReturn = Fixture.Create <TestableLotSummariesReturn>();

                MockLotService.Setup(m => m.GetLotSummaries(It.IsAny <FilterLotParameters>()))
                .Returns(new SuccessResult <ILotQualitySummariesReturn>(expectedReturn));

                // Act
                var results = SystemUnderTest.Get();

                // Assert
                Assert.IsNotNull(results);
                Assert.IsNotEmpty(results.LotSummaries);
            }
            public void ReturnsServiceResultOnSuccess()
            {
                // Arrange
                const int recordCount    = 10;
                var       expectedReturn = Fixture.Build <TestableLotSummariesReturn>()
                                           .With(m => m.LotSummaries, Fixture.CreateMany <ILotQualitySummaryReturn>(recordCount).AsQueryable())
                                           .Create();

                MockLotService.Setup(m => m.GetLotSummaries(It.IsAny <FilterLotParameters>()))
                .Returns(() => new SuccessResult <ILotQualitySummariesReturn>(expectedReturn));
                Assess.IsNotNull(expectedReturn);
                Assess.IsNotNull(expectedReturn.LotSummaries);

                // Act
                var result = LotsControler.Get(LotTypeEnum.Additive, pageSize: 10);

                // Assert
                MockLotService.Verify(m => m.GetLotSummaries(It.IsAny <FilterLotParameters>()), Times.Once());
                Assert.AreEqual(recordCount, result.LotSummaries.Count());
            }
            public void CreatesFilterLotParameterObjectCorrectly()
            {
                // Arrange
                const LotTypeEnum         expectedLotType = LotTypeEnum.GRP;
                const LotProductionStatus expectedStatus  = LotProductionStatus.Produced;

                FilterLotParameters actualParameters = null;

                MockLotService
                .Setup(m => m.GetLotSummaries(It.IsAny <FilterLotParameters>()))
                .Callback((FilterLotParameters param) => actualParameters = param)
                .Returns(new SuccessResult <ILotQualitySummariesReturn>(Fixture.Create <ILotQualitySummariesReturn>()));

                // Act
                LotsControler.Get(expectedLotType, expectedStatus);

                // Assert
                Assert.IsNotNull(actualParameters);
                Assert.AreEqual(expectedLotType, actualParameters.LotType);
                Assert.AreEqual(expectedStatus, actualParameters.ProductionStatus);
            }
            public void ParametersAreCorrectlyTransposedToDto()
            {
                // arrange
                ISetLotStatusParameters actualParameters = null;

                MockLotService.Setup(m => m.SetLotQualityStatus(It.IsAny <ISetLotStatusParameters>()))
                .Callback((ISetLotStatusParameters p) => actualParameters = p)
                .Returns(new SuccessResult <ILotStatInfoReturn>());
                const string           lotKey         = "12345";
                const LotQualityStatus expectedStatus = LotQualityStatus.Released;
                var dto = new SetLotStatusDto
                {
                    Status = expectedStatus
                };

                // act
                LotsControler.SetStatus(lotKey, dto);

                // assert
                Assert.IsNotNull(actualParameters);
                Assert.AreEqual(lotKey, actualParameters.LotKey);
                Assert.AreEqual(expectedStatus, actualParameters.QualityStatus);
            }
            public void UtilizesUserIdentityProvider()
            {
                // arrange
                const string           lotKey         = "12345";
                const LotQualityStatus expectedStatus = LotQualityStatus.Released;
                var dto = new SetLotStatusDto
                {
                    Status = expectedStatus
                };
                SetLotStatusParameter actualParameters = null;

                MockUserIdentityProvider.Setup(m => m.SetUserIdentity(It.IsAny <SetLotStatusParameter>()))
                .Callback((SetLotStatusParameter p) => actualParameters = p)
                .Returns(actualParameters);
                MockLotService.Setup(m => m.SetLotQualityStatus(It.IsAny <ISetLotStatusParameters>()))
                .Returns(new SuccessResult <ILotStatInfoReturn>());

                // act
                LotsControler.SetStatus(lotKey, dto);

                // assert
                Assert.IsNotNull(actualParameters);
                MockUserIdentityProvider.Verify(m => m.SetUserIdentity(actualParameters), Times.Once());
            }
Esempio n. 15
0
 public new void SetUp()
 {
     base.SetUp();
     MockLotService.Setup(m => m.SetLotHoldStatus(It.IsAny <ISetLotHoldStatusParameters>()))
     .Returns(new SuccessResult <ILotStatInfoReturn>());
 }