コード例 #1
0
        public void Submission_ShouldCallSubmitService_GetCategories(int id)
        {
            // Arrange
            var mockSubmitService          = new Mock <ISubmitService>();
            var mockAuthenticationProvider = new Mock <IAuthenticationProvider>();
            var mockViewModelFactory       = new Mock <IViewModelFactory>();

            var controller = new SubmitController(mockSubmitService.Object,
                                                  mockAuthenticationProvider.Object,
                                                  mockViewModelFactory.Object);

            var fakeSubmission = new Submission
            {
                CategoryId = 0,
                Condition  = "",
                Answers    = new List <SubmissionAnswer>()
            };

            mockSubmitService.Setup(x => x.GetSubmissionById(id)).Returns(fakeSubmission);

            //Act
            controller.Submission(id);

            //Assert
            mockSubmitService.Verify(x => x.GetSubmissionById(id), Times.Once);
        }
コード例 #2
0
        public void CreateSubmissin_ShouldRedirectToSubmission()
        {
            // Arrange
            var mockSubmitService          = new Mock <ISubmitService>();
            var mockAuthenticationProvider = new Mock <IAuthenticationProvider>();
            var mockViewModelFactory       = new Mock <IViewModelFactory>();

            var controller = new SubmitController(mockSubmitService.Object,
                                                  mockAuthenticationProvider.Object,
                                                  mockViewModelFactory.Object);

            var fakeNewSubmitViewModel = new NewSubmitViewModel();

            var fakeSubmission = new Submission
            {
                Id = 0
            };

            mockSubmitService.Setup(x => x.CreateSubmission(It.IsAny <string>(),
                                                            It.IsAny <int>(),
                                                            It.IsAny <string>(),
                                                            It.IsAny <string>(),
                                                            It.IsAny <string[]>()))
            .Returns(fakeSubmission);

            //Act
            controller.WithCallTo(x => x.New(fakeNewSubmitViewModel))
            .ShouldRedirectTo(x => x.Submission);
        }
コード例 #3
0
 /// <summary>页面加载
 /// </summary>
 protected void Page_Load(object sender, EventArgs e)
 {
     SubmitController = CreateSubmitInstance();
     if (!IsPostBack)
     {
     }
 }
コード例 #4
0
        public void CreateSubmission_ShouldCallSubmitServiceCreateSubmission()
        {
            // Arrange
            var mockSubmitService          = new Mock <ISubmitService>();
            var mockAuthenticationProvider = new Mock <IAuthenticationProvider>();
            var mockViewModelFactory       = new Mock <IViewModelFactory>();

            var controller = new SubmitController(mockSubmitService.Object,
                                                  mockAuthenticationProvider.Object,
                                                  mockViewModelFactory.Object);

            var fakeNewSubmitViewModel = new NewSubmitViewModel();

            var fakeSubmission = new Submission
            {
                Id = 0
            };

            mockSubmitService.Setup(x => x.CreateSubmission(It.IsAny <string>(),
                                                            It.IsAny <int>(),
                                                            It.IsAny <string>(),
                                                            It.IsAny <string>(),
                                                            It.IsAny <string[]>()))
            .Returns(fakeSubmission);

            //Act
            controller.New(fakeNewSubmitViewModel);

            //Assert
            mockSubmitService.Verify(x => x.CreateSubmission(It.IsAny <string>(),
                                                             It.IsAny <int>(),
                                                             It.IsAny <string>(),
                                                             It.IsAny <string>(),
                                                             It.IsAny <string[]>()), Times.Once);
        }
コード例 #5
0
 protected SubmitController CreateSubmitInstance()
 {
     if (ViewState["Checking"] == null)
     {
         _submitController     = new SubmitController(Guid.NewGuid(), 5);
         ViewState["Checking"] = _submitController;
     }
     return((SubmitController)ViewState["Checking"]);
 }
コード例 #6
0
 protected SubmitController CreateSubmitInstance()
 {
     if (ViewState["InsertGoodsOrder"] == null)
     {
         SubmitController = new SubmitController(Guid.NewGuid());
         ViewState["InsertGoodsOrder"] = SubmitController;
     }
     return((SubmitController)ViewState["InsertGoodsOrder"]);
 }
コード例 #7
0
 protected void Page_Load(object sender, EventArgs e)
 {
     _submitController = CreateSubmitInstance();
     if (!Page.IsPostBack)
     {
         RcbCompanyList.DataSource     = _companyCussent.GetCompanyCussentList(CompanyType.Express, State.Enable);
         RcbCompanyList.DataTextField  = "CompanyName";
         RcbCompanyList.DataValueField = "CompanyId";
         RcbCompanyList.DataBind();
         RcbCompanyList.Items.Insert(0, new RadComboBoxItem("", Guid.Empty.ToString()));
     }
 }
コード例 #8
0
 /// <summary>
 /// 60s内禁止重复提交
 /// </summary>
 protected void CreateSubmitController()
 {
     if (ViewState["SubmitControllerSave"] == null)
     {
         _submitController = new SubmitController();
         ViewState["SubmitControllerSave"] = _submitController;
     }
     else
     {
         _submitController = (SubmitController)ViewState["SubmitControllerSave"];
     }
 }
コード例 #9
0
ファイル: IndexTests.cs プロジェクト: KristiyanVachev/Leaf
        public void Index_ShouldRenderDefaultView()
        {
            // Arrange
            var mockSubmitService          = new Mock <ISubmitService>();
            var mockAuthenticationProvider = new Mock <IAuthenticationProvider>();
            var mockViewModelFactory       = new Mock <IViewModelFactory>();

            var controller = new SubmitController(mockSubmitService.Object,
                                                  mockAuthenticationProvider.Object,
                                                  mockViewModelFactory.Object);

            //Act && Assert
            controller.WithCallTo(x => x.Index()).ShouldRenderDefaultView();
        }
コード例 #10
0
        public void Constructor_ShouldInitializeCorrectly()
        {
            // Arrange
            var mockSubmitService          = new Mock <ISubmitService>();
            var mockAuthenticationProvider = new Mock <IAuthenticationProvider>();
            var mockViewModelFactory       = new Mock <IViewModelFactory>();

            // Act
            var controller = new SubmitController(mockSubmitService.Object,
                                                  mockAuthenticationProvider.Object,
                                                  mockViewModelFactory.Object);

            // Assert
            Assert.IsNotNull(controller);
        }
コード例 #11
0
 protected void Page_Load(object sender, EventArgs e)
 {
     _submitController = CreateSubmitInstance();
     if (!IsPostBack)
     {
         //绑定借记单状态
         RCB_State.DataSource = GetDebitNoteStateList();
         RCB_State.DataBind();
         //绑定仓库
         RCB_Warehouse.DataSource = WarehouseDic;
         RCB_Warehouse.DataBind();
         //绑定责任人
         RCB_Persion.DataSource = PersonnelList;
         RCB_Persion.DataBind();
         //绑定供应商
         RCB_Company.DataSource = CompanyCussentList;
         RCB_Company.DataBind();
     }
 }
コード例 #12
0
        public PublisherSubscriberFixture()
        {
            var env = Environment.GetEnvironmentVariable("KAFKA_DIFF_ENV");

            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile(
                path: string.IsNullOrWhiteSpace(env)
                        ? "settings.json"
                        : $"settings.{env}.json",
                optional: false)
                          .AddEnvironmentVariables();

            var configuration = builder.Build();

            var settings = new Settings();

            configuration.Bind(settings);

            PublisherAutofacModule.KafkaServer  = settings.KafkaServer;
            SubscriberAutofacModule.KafkaServer = settings.KafkaServer;

            var publisherContainerBuilder = new ContainerBuilder();

            publisherContainerBuilder.RegisterModule <PublisherAutofacModule>();
            publisherContainerBuilder.RegisterType <SubmitController>().SingleInstance();
            var publisherContainer = publisherContainerBuilder.Build();

            _submitController = publisherContainer.Resolve <SubmitController>();

            var subscriberContainerBuilder = new ContainerBuilder();

            subscriberContainerBuilder.RegisterModule <SubscriberAutofacModule>();
            subscriberContainerBuilder.RegisterType <DiffController>().SingleInstance();
            var subscriberContainer = subscriberContainerBuilder.Build();

            _diffController = subscriberContainer.Resolve <DiffController>();
            _diffController.StartWorker();
        }
コード例 #13
0
        public void Submission_ShouldRenderDefaultView(int id)
        {
            // Arrange
            var mockSubmitService          = new Mock <ISubmitService>();
            var mockAuthenticationProvider = new Mock <IAuthenticationProvider>();
            var mockViewModelFactory       = new Mock <IViewModelFactory>();

            var controller = new SubmitController(mockSubmitService.Object,
                                                  mockAuthenticationProvider.Object,
                                                  mockViewModelFactory.Object);

            var fakeSubmission = new Submission
            {
                CategoryId = 0,
                Condition  = "",
                Answers    = new List <SubmissionAnswer>()
            };

            mockSubmitService.Setup(x => x.GetSubmissionById(id)).Returns(fakeSubmission);


            //Act && Assert
            controller.WithCallTo(x => x.Submission(id)).ShouldRenderDefaultView();
        }
コード例 #14
0
 protected SubmitControllerFixture()
 {
     _sut = new SubmitController(_submitHandler);
 }