Пример #1
0
        /// <summary>
        /// Setup the test
        /// </summary>
        public ServiceAreaApiUnitTest()
        {
            DbContextOptions <DbAppContext> options      = new DbContextOptions <DbAppContext>();
            Mock <DbAppContext>             dbAppContext = new Mock <DbAppContext>(null, options);
            ServiceAreaService _service = new ServiceAreaService(dbAppContext.Object);

            _ServiceAreaApi = new ServiceAreaController(_service);
        }
Пример #2
0
            public static R GetRule(string RuleKey, T value)
            {
                Engine eng = new Engine();
                T      GenProperty;
                R      ReturnType = default(R);

                switch (RuleKey)
                {
                case "ServiceArea":
                    eng.For <ServiceArea>()
                    .Setup(S => S.Pin)
                    .MustNotBeNullOrEmpty();
                    dynamic dynVar            = value;
                    ServiceAreaController SAC = new ServiceAreaController();
                    return(eng.Validate(dynVar) ? SAC.GetServiceableArea(dynVar.Pin) : ReturnType);

                    break;


                case "CustomerExists":
                    eng.For <Customer>()
                    .Setup(S => S.Mobile)
                    .MustNotBeNullOrEmpty();
                    return(ReturnType);

                    break;

                case "Registration":
                    eng.For <Customer>()
                    .Setup(S => S.Mobile)
                    .MustNotBeNullOrEmpty()
                    .Setup(S => S.FirstName)
                    .MustNotBeNullOrEmpty()
                    .Setup(S => S.LastName)
                    .MustNotBeNullOrEmpty()
                    .Setup(S => S.Age)
                    .MustNotBeNullOrEmpty();

                    (chkServicablity())? chkAvailability()

                    return(ReturnType);

                    break;

                default:
                    return(ReturnType);

                    break;
                }
            }
Пример #3
0
        /// <summary>
        /// Setup the test
        /// </summary>
        public ServiceAreaApiUnitTest()
        {
            DbContextOptions <DbAppContext> options      = new DbContextOptions <DbAppContext>();
            Mock <DbAppContext>             dbAppContext = new Mock <DbAppContext>(null, options);

            /*
             *
             * Here you will need to mock up the context.
             *
             * ItemType fakeItem = new ItemType(...);
             *
             * Mock<DbSet<ItemType>> mockList = MockDbSet.Create(fakeItem);
             *
             * dbAppContext.Setup(x => x.ModelEndpoint).Returns(mockItem.Object);
             *
             */

            ServiceAreaService _service = new ServiceAreaService(dbAppContext.Object);

            _ServiceAreaApi = new ServiceAreaController(_service);
        }