コード例 #1
0
ファイル: ServiceAreaTestsUnit.cs プロジェクト: rstens/hets
        /// <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);
        }