public void IsAdd_InputIs1_ShouldBeReturn2()
        {
            var service = new TestService();
            int result  = service.Add(1);

            Assert.Equal(2, result);
        }
Ejemplo n.º 2
0
        private static void AddTest()
        {
            var test = new Test
            {
                Name              = Console.GetInput(TextForOutput.EnterNameToAdd),
                Title             = Console.GetInput(TextForOutput.EnterTopic),
                QuestionsNumber   = Console.GetIntValue(TextForOutput.EnterQuestionsNumber),
                IsClosedQuestions =
                    Console.GetBoolValue(TextForOutput.ChooseQuestionsType)
            };

            if (test.IsClosedQuestions)
            {
                test.IsIndicateAnswers =
                    Console.GetBoolValue(TextForOutput.EnableIndicateCorrectAnswer);

                test.IsScoreShown = Console.GetBoolValue(TextForOutput.EnableShowGrade);
            }

            test.TimerValue = Console.GetIntValue(TextForOutput.EnterTimerValue);

            TestService.Add(test);

            for (var i = 1; i <= test.QuestionsNumber; i++)
            {
                AddQuestion(test, i);
            }
        }
Ejemplo n.º 3
0
        public void Add_IfAdd_AddsSuccess()
        {
            // arrange
            var entity = new TestEntity
            {
                Id    = 1,
                Title = Guid.NewGuid().ToString()
            };
            var dto = new TestDTO
            {
                Id    = 1,
                Title = Guid.NewGuid().ToString()
            };

            _mapperMock.Setup(_ => _.Map <TestDTO, TestEntity>(dto)).Returns(entity);
            _currentRepositoryMock.Setup(_ => _.Insert(entity));
            _unitOfWorkMock.Setup(_ => _.Commit());
            _mapperMock.Setup(_ => _.Map <TestEntity, TestDTO>(entity)).Returns(dto);

            // act
            var result = _sut.Add(dto);

            // assert
            Assert.Equal(dto, result);
            _mapperMock.Verify(_ => _.Map <TestDTO, TestEntity>(dto), Times.Once);
            _currentRepositoryMock.Verify(_ => _.Insert(entity), Times.Once);
            _unitOfWorkMock.Verify(_ => _.Commit(), Times.Once);
            _mapperMock.Verify(_ => _.Map <TestEntity, TestDTO>(entity), Times.Once);
        }
Ejemplo n.º 4
0
        public void TestAddMethodWithTwoPositiveNumbers()
        {
            var testService = new TestService();

            int result = testService.Add(2, 5);

            Assert.Equal(7, result);
        }
Ejemplo n.º 5
0
        public void TestAddMethodWithTwoPositiveNumbers()
        {
            //Arrange - instan. classes etc.
            var testService = new TestService();

            //Act - Call the method to test
            int result = testService.Add(2, 5);

            //Assert - Check if you get the right result back
            Assert.Equal(7, result);
        }
Ejemplo n.º 6
0
 public ActionResult CreateTest(TestModel projectVM)
 {
     Domain.Entity.Test p = new Domain.Entity.Test
     {
         Id       = projectVM.Id,
         TypeTest = projectVM.TypeTest,
         Version  = projectVM.Version,
     };
     ts.Add(p);
     ts.Commit();
     return(new HttpStatusCodeResult(System.Net.HttpStatusCode.OK));
 }
Ejemplo n.º 7
0
        public ActionResult GetTest()
        {
            TestService.Add(new Model.Test {
                Name = "dd", Test1 = "131333", ID = Guid.NewGuid().ToString()
            });

            var    data  = TestService.GetModels(p => true);
            ICache cache = CacheFactory.CaChe();

            cache.Write("TestData", "aaaaaaaaaaaaaaaaaaaaa", 0);

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 8
0
        public string Test(string sayi)
        {
            int i = Convert.ToInt32(sayi);

            TestService.Add(i);

            try
            {
                var s = Anketbaz.Data.EntityConnectionService.User.GetList(x => x.authkey == "test");
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message + ex.InnerException.Message + ex.StackTrace);
            }

            return("Hello World!");
        }
Ejemplo n.º 9
0
        public void RegisteredServiceCanBeAccessedWithGetService()
        {
            var hostFactory = (IsolatedAppDomainHostFactory)RuntimeAccessor.ServiceLocator.ResolveByComponentId(IsolatedAppDomainHostFactory.ComponentId);

            using (IHost host = hostFactory.CreateHost(new HostSetup(), new MarkupStreamLogger(TestLog.Default)))
            {
                HostAssemblyResolverHook.InstallCallback(host);

                host.GetHostService().Do <object, object>(RemoteCallback, null);

                using (BinaryIpcClientChannel clientChannel = new BinaryIpcClientChannel(PortName))
                {
                    TestService serviceProxy =
                        (TestService)clientChannel.GetService(typeof(TestService), ServiceName);
                    Assert.AreEqual(42, serviceProxy.Add(23, 19));
                }
            }
        }
        public ActionResult Create(Test test)
        {
            Test p = new Test();

            try
            {
                // TODO: Add insert logic here
                p.TypeTest = test.TypeTest;
                p.Version  = test.Version;
                testservice.Add(p);
                testservice.Commit();

                return(RedirectToAction("index", "Home"));
            }
            catch
            {
                return(View());
            }
        }
Ejemplo n.º 11
0
        private void btn_createTest_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txt_testName.Text) && cbo_category.SelectedIndex != -1)
            {
                GetCategoryID(out int categoryID);

                TestModel testModel = new TestModel()
                {
                    TestName    = txt_testName.Text,
                    CategoryID  = categoryID,
                    isLiveCheck = rbtn_no.Checked ? true : false,
                    OwnerID     = OwnerID
                };

                if (!GetTimeValue(testModel))
                {
                    return;
                }

                TestService testService = new TestService();
                if (btn_createTest.Text == "Update")
                {
                    testModel.TestID = TestID;

                    if (testService.Update(testModel))
                    {
                        MessageBox.Show("Updated successfully.", "Done");
                    }
                }
                else
                {
                    testService.Add(testModel);
                    MessageBox.Show("Created successfully.", "Done");
                }

                this.Close();
            }
            else
            {
                MessageBox.Show("Please name the test and select at least a category.", "Error");
            }
        }
Ejemplo n.º 12
0
 public async Task <IActionResult> Add([FromBody] TestModel model)
 {
     return(Ok(await service.Add(model)));
 }
Ejemplo n.º 13
0
        public async Task <IActionResult> Add(string name)
        {
            await tests.Add(new Test { Name = name });

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 14
0
 public ActionResult Create(Test p)
 {
     cs.Add(p);
     cs.Commit();
     return(RedirectToAction("ShowTests"));
 }