Ejemplo n.º 1
0
 public TestForm(int testId)
 {
     InitializeComponent();
     _presenter = new TestPresenter(this);
     _presenter.LoadTest(testId);
     EndTest = new Action(() => this.Close());
 }
Ejemplo n.º 2
0
        private void CallbackMatcherTest5(Mock <IParentInterface> mock)
        {
            var c = new CallbackMatcher <Action>();
            var v = new Version(1, 2, 3, 4);

            mock.Expects.AtLeastOne.SetProperty(_ => _.ReadWriteObjectProperty).To(Is.TypeOf <Version>());

            using (Factory.Ordered())
            {
                mock.Expects.AtLeastOne.SetProperty(_ => _[4, 5]).To(Is.TypeOf <DateTime>());
                mock.Expects.One.Method(_ => _.AsyncMethod((Action)null)).With(c);
            }

            var p = new TestPresenter(mock.MockObject);

            p.SetPropertyOfMockToInternalValue();
            p.SetPropertyOfMockToInternalValue();
            p.SetIndexerPropertyOfMockToInternalValue();
            p.SetIndexerPropertyOfMockToInternalValue();
            p.BeginInvoke();

            c.Callback();

            Assert.AreEqual(TestPresenter.END_INVOKE, p.Status);
        }
Ejemplo n.º 3
0
        private async Task ProcessTestsByCourseId(int courseId)
        {
            var service = new TestService();
            var result  = await service.GetTestsByCourseId(courseId);

            Tests = TestPresenter.GetTestPresenters(result, Enrollment.Level);
        }
Ejemplo n.º 4
0
        public async Task ProcessTestsByCourseId(int courseId)
        {
            var service = new TestService();
            var result  = await service.GetTestsByCourseId(courseId);

            Tests = TestPresenter.GetTestPresenters(result);
            Tests.Add(new NewTestPresenter());
        }
Ejemplo n.º 5
0
 private void testToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (!FormBuilder.IsFormUnique(this, FormEnum.Test))
     {
         var test          = new SetupForm(FormEnum.Test);
         var testPresenter = new TestPresenter(test);
         test.MdiParent = this;
         test.Show();
     }
 }
Ejemplo n.º 6
0
 public ModeCommand(TestMode mode, TestPresenter presenter, Test test, ITestView view)
     : base(() =>
     {
         presenter.EnableMode(mode);
         mode.Refresh();
         view.PlaceInMainPane(mode.ContentView);
     })
 {
     _test = test;
     _mode = mode;
 }
Ejemplo n.º 7
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new Form1());

            using (var view = new TestView())
            using (var pres = new TestPresenter(view))
            {
                pres.Display();
            }
        }
Ejemplo n.º 8
0
        private void GetPropertyPreviousSetterIndexer(Mock <IParentInterface> mock)
        {
            var presenter = new TestPresenter(mock.MockObject);

            mock.Expects.One.SetProperty(_ => _[4, 5]).To(Is.TypeOf <DateTime>());
            mock.Expects.One.GetProperty(_ => _[4, 5]).WillReturnSetterValue();

            presenter.SetIndexerPropertyOfMockToInternalValue();

            Assert.AreEqual(new DateTime(2011, 5, 1), mock.MockObject[4, 5]);

            //just checking if it can be done twice
            mock.Expects.One.GetProperty(_ => _[4, 5]).WillReturnSetterValue();
            Assert.AreEqual(new DateTime(2011, 5, 1), mock.MockObject[4, 5]);
        }
Ejemplo n.º 9
0
        private void GetPropertyPreviousSetter2Test(Mock <IParentInterface> mock)
        {
            var expectations = new Expectations(2);

            expectations[0] = mock.Arrange(_ => _.ReadWriteObjectProperty).To(Is.TypeOf <Version>());
            expectations[1] = mock.Arrange(_ => _.ReadWriteObjectProperty).WillReturnSetterValue();

            var presenter = new TestPresenter(mock.MockObject);

            presenter.SetPropertyOfMockToInternalValue();

            Assert.AreEqual(5, mock.MockObject.ReadWriteObjectProperty.Major);

            expectations.ForEach(_ => _.Assert());
        }
Ejemplo n.º 10
0
        private void CallbackMatcherTest3(Mock <IParentInterface> mock)
        {
            var callback = new CallbackMatcher <Action>();

            mock.Expects.One.Method(_ => _.AsyncMethod((Action)null)).With(callback);

            var presenter = new TestPresenter(mock.MockObject);

            presenter.ShowDialog();

            Assert.IsNull(presenter.Status);

            callback.Callback();

            Assert.AreEqual(TestPresenter.SHOW_DIALOG, presenter.Status);
        }
Ejemplo n.º 11
0
        public void FakeTest1()
        {
            //arrange
            var fake      = new Fake <IParentInterface>();
            var presenter = new TestPresenter(fake.MockObject);

            //act
            presenter.SetPropertyOfMockToInternalValue();
            presenter.SetIndexerPropertyOfMockToInternalValue();
            presenter.BeginInvoke();
            presenter.HookUpStandardEvent1();

            //assert
            fake.PropertyIs(_ => _.ReadWriteObjectProperty = new Version(5, 6, 7, 8));
            fake.Property(_ => _.ReadWriteObjectProperty).Is(new Version(5, 6, 7, 8));
        }
Ejemplo n.º 12
0
        private void CallbackMatcherTest1(Mock <IParentInterface> mock)
        {
            var callback = new CallbackMatcher <Action>();

            mock.Expects.One.Method(_ => _.AsyncMethod((Action)null)).With(callback);

            var presenter = new TestPresenter(mock.MockObject);

            presenter.BeginInvoke();

            Assert.IsTrue(string.IsNullOrEmpty(presenter.Status));

            callback.Callback();

            Assert.AreEqual(TestPresenter.END_INVOKE, presenter.Status);
        }
Ejemplo n.º 13
0
        public void Presenter_Response_ReturnsResponseFromHttpContext()
        {
            // Arrange
            var view        = MockRepository.GenerateStub <IView>();
            var httpContext = MockRepository.GenerateStub <HttpContextBase>();
            var response    = MockRepository.GenerateStub <HttpResponseBase>();

            httpContext.Stub(h => h.Response).Return(response);

            // Act
            var presenter = new TestPresenter(view)
            {
                HttpContext = httpContext
            };

            // Assert
            Assert.AreSame(response, presenter.Response);
        }
Ejemplo n.º 14
0
        public void Presenter_Cache_ReturnsCacheFromHttpContext()
        {
            // Arrange
            var view        = MockRepository.GenerateStub <IView>();
            var httpContext = MockRepository.GenerateStub <HttpContextBase>();
            var cache       = new Cache();

            httpContext.Stub(h => h.Cache).Return(cache);

            // Act
            var presenter = new TestPresenter(view)
            {
                HttpContext = httpContext
            };

            // Assert
            Assert.AreSame(cache, presenter.Cache);
        }
Ejemplo n.º 15
0
        public void Presenter_Server_ReturnsServerFromHttpContext()
        {
            // Arrange
            var view        = MockRepository.GenerateStub <IView>();
            var httpContext = MockRepository.GenerateStub <HttpContextBase>();
            var server      = MockRepository.GenerateStub <HttpServerUtilityBase>();

            httpContext.Stub(h => h.Server).Return(server);

            // Act
            var presenter = new TestPresenter(view)
            {
                HttpContext = httpContext
            };

            // Assert
            Assert.AreSame(server, presenter.Server);
        }
Ejemplo n.º 16
0
        private async void GridView_ItemClick(object sender, ItemClickEventArgs e)
        {
            TestPresenter test = (TestPresenter)e.ClickedItem;

            if (test.HigherThanEnrollmentLevel)
            {
                var dialog = new ContentDialog
                {
                    Content         = "A feladatsor csak az alsóbb szintek\nelvégzése után lesz elérhető.",
                    CloseButtonText = "Ok"
                };
                await dialog.ShowAsync();
            }
            else
            {
                ViewModel.StartTest(test.Test);
            }
        }
Ejemplo n.º 17
0
        public void CallbackMatcherTest2(Mock <IParentInterface> mock)
        {
            var callback = new CallbackMatcher <Action <IEnumerable <Version> > >();

            mock.Expects.One.Method(_ => _.AsyncMethod((Action <IEnumerable <Version> >)null)).With(callback);

            var presenter = new TestPresenter(mock.MockObject);

            presenter.BeginIEnumerableInvoke();

            Assert.IsTrue(string.IsNullOrEmpty(presenter.Status));

            var versions = new List <Version> {
                new Version(1, 1, 1, 1), new Version(2, 2, 2, 2), new Version(3, 3, 3, 3)
            };

            callback.Callback(versions);

            Assert.AreEqual(string.Format(TestPresenter.END_INVOKE_COUNT, 3), presenter.Status);
        }
Ejemplo n.º 18
0
        private void ArrangeTest1(Mock <IParentInterface> mock)
        {
            var expectations = new Expectations(5);

            expectations[0] = mock.Arrange(_ => _.Method(3)).WillReturn(true);
            expectations[1] = mock.Arrange(_ => _.MethodVoid(new Version(1, 1, 1, 1))).With(new Version(3, 3, 3, 3));
            expectations[2] = mock.Arrange(_ => _.ReadOnlyValueProperty).WillReturn(3);
            expectations[3] = mock.Arrange(_ => _.WriteOnlyObjectProperty = new Version(2, 2, 2, 2));
            expectations[4] = mock.Arrange(_ => _.StandardEvent1 += null);

            var p  = new TestPresenter(mock.MockObject);
            var b1 = p.CallMethod(3);

            p.CallVoidMethod(new Version(3, 3, 3, 3));
            var b2 = p.GetReadOnlyValueProperty();

            p.AssignWriteOnlyObjectProperty(new Version(2, 2, 2, 2));
            p.HookUpStandardEvent1();

            expectations.ForEach(_ => _.Assert());
            Assert.IsTrue(b1);
            Assert.AreEqual(3, b2);
        }
Ejemplo n.º 19
0
        public void Presenter_RouteData_ReturnsRouteDataFromHttpContext()
        {
            // Arrange
            var view        = MockRepository.GenerateStub <IView>();
            var httpContext = MockRepository.GenerateStub <HttpContextBase>();
            var request     = MockRepository.GenerateStub <HttpRequestBase>();

            httpContext.Stub(h => h.Request).Return(request);
            var route     = MockRepository.GenerateStub <RouteBase>();
            var routeData = new RouteData();

            routeData.Values.Add("TestRouteDataValue", 1);
            route.Stub(r => r.GetRouteData(httpContext)).Return(routeData);
            RouteTable.Routes.Add("Test Route", route);

            // Act
            var presenter = new TestPresenter(view)
            {
                HttpContext = httpContext
            };

            // Assert
            Assert.AreEqual(1, presenter.RouteData.Values["TestRouteDataValue"]);
        }
Ejemplo n.º 20
0
        public void CallbackListMatcherTest1()
        {
            var callback = new CallbackListMatcher <Action <IEnumerable <Version> > >();

            _mock.Expects.Exactly(2).Method(_ => _.AsyncMethod((Action <IEnumerable <Version> >)null)).With(callback);

            TestPresenter presenter1 = new TestPresenter(_mock.MockObject);
            TestPresenter presenter2 = new TestPresenter(_mock.MockObject);

            presenter1.BeginIEnumerableInvoke();
            presenter2.BeginIEnumerableInvoke();

            Assert.IsTrue(string.IsNullOrEmpty(presenter1.Status));
            Assert.IsTrue(string.IsNullOrEmpty(presenter2.Status));

            var versions = new List <Version> {
                new Version(1, 1, 1, 1), new Version(2, 2, 2, 2), new Version(3, 3, 3, 3)
            };

            callback.Callbacks.ForEach(_ => _.Invoke(versions));

            Assert.AreEqual(string.Format(TestPresenter.END_INVOKE_COUNT, 3), presenter1.Status);
            Assert.AreEqual(string.Format(TestPresenter.END_INVOKE_COUNT, 3), presenter2.Status);
        }
Ejemplo n.º 21
0
 private void testToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (!FormBuilder.IsFormUnique(this, FormEnum.Test))
     {
         var test = new SetupForm(FormEnum.Test);
         var testPresenter = new TestPresenter(test);
         test.MdiParent = this;
         test.Show();
     }
 }