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); }
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); }
/// <summary>页面加载 /// </summary> protected void Page_Load(object sender, EventArgs e) { SubmitController = CreateSubmitInstance(); if (!IsPostBack) { } }
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); }
protected SubmitController CreateSubmitInstance() { if (ViewState["Checking"] == null) { _submitController = new SubmitController(Guid.NewGuid(), 5); ViewState["Checking"] = _submitController; } return((SubmitController)ViewState["Checking"]); }
protected SubmitController CreateSubmitInstance() { if (ViewState["InsertGoodsOrder"] == null) { SubmitController = new SubmitController(Guid.NewGuid()); ViewState["InsertGoodsOrder"] = SubmitController; } return((SubmitController)ViewState["InsertGoodsOrder"]); }
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())); } }
/// <summary> /// 60s内禁止重复提交 /// </summary> protected void CreateSubmitController() { if (ViewState["SubmitControllerSave"] == null) { _submitController = new SubmitController(); ViewState["SubmitControllerSave"] = _submitController; } else { _submitController = (SubmitController)ViewState["SubmitControllerSave"]; } }
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(); }
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); }
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(); } }
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(); }
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(); }
protected SubmitControllerFixture() { _sut = new SubmitController(_submitHandler); }