コード例 #1
0
            public void UtilizesUserIdentityProvider()
            {
                // arrange
                const string custKey           = "1234";
                const string productKey        = "asdf";
                var          values            = AutoFixtureHelper.BuildFixture().Create <SetCustomerProductRangesRequest>();
                const string expectedUserToken = "USER123";

                MockUserIdentityProvider.Setup(m => m.SetUserIdentity(It.IsAny <IUserIdentifiable>()))
                .Callback((IUserIdentifiable t) =>
                {
                    t.UserToken = expectedUserToken;
                });

                ISetCustomerProductAttributeRangesParameters actualValues = null;

                MockCustomerService.Setup(m => m.SetCustomerChileProductAttributeRanges(It.IsAny <ISetCustomerProductAttributeRangesParameters>()))
                .Callback((ISetCustomerProductAttributeRangesParameters p) => actualValues = p)
                .Returns(new SuccessResult());

                // act
                SystemUnderTest.Post(custKey, productKey, values);

                // assert
                Assert.IsNotNull(actualValues);
                Assert.AreEqual(expectedUserToken, actualValues.UserToken);
            }
コード例 #2
0
 public void SetUp()
 {
     MockLotService           = new Mock <ILotService>();
     MockUserIdentityProvider = new Mock <IUserIdentityProvider>();
     MockUserIdentityProvider.Setup(m => m.SetUserIdentity(It.IsAny <IUserIdentifiable>())).Verifiable();
     SystemUnderTest = new LotHoldsController(MockLotService.Object, MockUserIdentityProvider.Object);
     Fixture         = AutoFixtureHelper.BuildFixture();
 }
コード例 #3
0
            public void Tests()
            {
                // arrange
                var expectedResult = AutoFixtureHelper.BuildFixture().Create <ICustomerChileProductAttributeRangesReturn>();

                MockCustomerService.Setup(m => m.GetCustomerChileProductAttributeRanges(It.IsAny <string>(), It.IsAny <string>()))
                .Returns(new SuccessResult <ICustomerChileProductAttributeRangesReturn>(expectedResult));

                // act
                SystemUnderTest.Get("1234", "asdf");

                Assert.Pass();
            }
コード例 #4
0
            public void ParametersAreCorrectlyParsedIntoDataTransferObject()
            {
                // arrange
                const string custKey    = "1234";
                const string productKey = "asdf";
                var          values     = AutoFixtureHelper.BuildFixture().Create <SetCustomerProductRangesRequest>();
                ISetCustomerProductAttributeRangesParameters actualValues = null;

                MockCustomerService.Setup(m => m.SetCustomerChileProductAttributeRanges(It.IsAny <ISetCustomerProductAttributeRangesParameters>()))
                .Callback((ISetCustomerProductAttributeRangesParameters p) => actualValues = p)
                .Returns(new SuccessResult());

                // act
                SystemUnderTest.Post(custKey, productKey, values);

                // assert
                Assert.IsNotNull(actualValues);
                Assert.AreEqual(custKey, actualValues.CustomerKey);
                Assert.AreEqual(productKey, productKey);
            }
コード例 #5
0
        public void Is_Configuration_Valid()
        {
            Client.Mvc.AutoMapperConfiguration.Configure();
            Client.Reporting.AutoMapperConfiguration.Configure();

            var abstractFound = false;

            foreach (var mapping in Mapper.GetAllTypeMaps())
            {
                foreach (var propertyMap in (mapping.GetPropertyMaps() ?? new PropertyMap[0]).ToList())
                {
                    CheckPropertyMap(propertyMap);
                }

                if (mapping.DestinationType.IsAbstract && mapping.CustomMapper == null && mapping.DestinationCtor == null)
                {
                    abstractFound = true;
                    Console.WriteLine("- Abstract DestinationType '{0}' without customer mapper or destination constructor.", mapping.DestinationType);
                }
                else
                {
                    if (mapping.SourceType.IsValueType && mapping.DestinationType.IsValueType &&
                        mapping.SourceType.IsGenericType && mapping.SourceType.GetGenericTypeDefinition() == NullableDefinition &&
                        mapping.SourceType == NullableDefinition.MakeGenericType(mapping.DestinationType))
                    {
                        AssertNullableMapping(mapping.DestinationType);
                    }
                    else if (!mapping.SourceType.IsGenericTypeDefinition)
                    {
                        if (mapping.SourceType.IsInterface)
                        {
                            AssertInterfaceMapping(mapping.SourceType, mapping.DestinationType);
                        }
                        else if (!mapping.SourceType.IsAbstract)
                        {
                            AssertMapping(mapping.SourceType, mapping.DestinationType, AutoFixtureHelper.BuildFixture());
                        }
                    }
                }
            }

            if (abstractFound)
            {
                Assert.Fail("Abstract destination type(s) with no custom mapping found.");
            }
        }