示例#1
0
        public void ProcessReturnsEmptyString()
        {
            var template = new TestTemplate();
            string result = template.Process();

            Assert.AreEqual(string.Empty, result);
        }
示例#2
0
        public void ProcessCallsProcessInternal()
        {
            var template = new TestTemplate();
            template.Process();

            Assert.IsTrue(template.ProcessInternalCalled);
        }
示例#3
0
        public void WriteWritesToContent()
        {
            var template = new TestTemplate();
            template.Write("foo");
            string result = template.Process();

            Assert.AreEqual("foo", result);
        }
        public void ResourceWithPropertiesSetter()
        {
            // Arrange
            var resource = new Types.Resources.Deployment()
                           .WithProperties(x =>
            {
                x.Mode             = DeploymentMode.Complete;
                x.TemplateLink.Uri = "value";
            });

            var template = new TestTemplate()
                           .WithResources(resource);

            // Act
            var result = template.ToJson(_options);

            // Assert
            var expected = @"{
              ""$schema"":""{DefaultTemplateSchema}"",
              ""contentVersion"":""{DefaultContentVersion}"",
              ""resources"": [
                {
                  ""type"": ""{DefaultResourceType}"",
                  ""apiVersion"": ""{DefaultApiVersion}"",
                  ""name"": """",
                  ""properties"": {
                    ""mode"": ""Complete"",
                    ""templateLink"": {
                      ""uri"": ""value""
                    }
                  },
                }
              ],
              ""outputs"": {}
            }";

            expected = expected
                       .Replace("{DefaultResourceType}", resource.Type)
                       .Replace("{DefaultApiVersion}", resource.ApiVersion);

            JsonShouldBeEquivalent(expected, result);
        }
示例#5
0
        private async Task AddTestTemplate()
        {
            var questions = new List <Question>
            {
                new Question("QContent", new WrittenAnswer("Answer", 1f), fixture.UserId),
                new Question("QContent2", new WrittenAnswer("Answer2", 1f), fixture.UserId),
            };
            await fixture.ExecuteDbContext(db =>
            {
                db.Questions.AddRange(questions);
                return(db.SaveChangesAsync());
            });

            TestTemplate = new TestTemplate("TestTemplate#1", fixture.UserId, questions.Select(x => x.Id));
            await fixture.ExecuteDbContext(db =>
            {
                db.TestTemplates.Add(TestTemplate);
                return(db.SaveChangesAsync());
            });
        }
        public void ResourceWithObjectOutput()
        {
            // Arrange
            var mapping = new Dictionary <string, string>
            {
                { "key1", "value1" },
                { "key2", "value2" },
            };

            var template = new TestTemplate()
                           .WithOutputs(Output.Object("key1", mapping, isSecure: false))
                           .WithOutputs(Output.Object("key2", mapping, isSecure: true));

            // Act
            var result = template.ToJson(_options);

            // Assert
            var expected = @"{
              ""$schema"":""{DefaultTemplateSchema}"",
              ""contentVersion"":""{DefaultContentVersion}"",
              ""resources"": [],
              ""outputs"": {
                ""key1"": {
                  ""type"": ""object"",
                  ""value"": {
                    ""key1"": ""value1"",
                    ""key2"": ""value2""
                  }
                },
                ""key2"": {
                  ""type"": ""secureobject"",
                  ""value"": {
                    ""key1"": ""value1"",
                    ""key2"": ""value2""
                  }
                }
              }
            }";

            JsonShouldBeEquivalent(expected, result);
        }
        public void ResourceWithArrayOfObjectOutput()
        {
            // Arrange
            var mappings = new List <Dictionary <string, string> >
            {
                new Dictionary <string, string> {
                    { "key1", "value1" }
                },
                new Dictionary <string, string> {
                    { "key2", "value2" }
                },
            };

            var template = new TestTemplate()
                           .WithOutputs(Output.Array("key", mappings));

            // Act
            var result = template.ToJson(_options);

            // Assert
            var expected = @"{
              ""$schema"":""{DefaultTemplateSchema}"",
              ""contentVersion"":""{DefaultContentVersion}"",
              ""resources"": [],
              ""outputs"": {
                ""key"": {
                  ""type"": ""array"",
                  ""value"": [
                    {
                      ""key1"": ""value1""
                    },
                    {
                      ""key2"": ""value2""
                    }
                  ]
                }
              }
            }";

            JsonShouldBeEquivalent(expected, result);
        }
        public void ResourceWithPropertiesWithTemplateLoop()
        {
            // Arrange
            var resource = new TestResource();

            resource.Properties = new TestProperties
            {
                TemplateProp = new TestTemplate()
                               .WithResources(resource),
            };

            var template = new TestTemplate()
                           .WithResources(resource);

            // Act
            var result = template.ToJson(_options);

            // Assert
            var expected = @"{
              ""$schema"":""{DefaultTemplateSchema}"",
              ""contentVersion"":""{DefaultContentVersion}"",
              ""resources"": [
                {
                  ""type"": ""{DefaultResourceType}"",
                  ""apiVersion"": ""{DefaultApiVersion}"",
                  ""name"": """",
                  ""properties"": {
                    ""templateProp"": {
                      ""$schema"":""{DefaultTemplateSchema}"",
                      ""contentVersion"":""{DefaultContentVersion}"",
                      ""resources"": [],
                      ""outputs"": {}
                    }
                  },
                }
              ],
              ""outputs"": {}
            }";

            JsonShouldBeEquivalent(expected, result);
        }
        public ActionResult CreateTestScheme(CreateTestSchemeVM testVM)
        {
            if (ModelState.IsValid)
            {
                List <int> questionsIDs = new List <int>();
                foreach (questionInfo question in testVM.questionList)
                {
                    if (question.isChecked == true)
                    {
                        questionsIDs.Add(question.questionID);
                    }
                }
                TestTemplate testTemplate = testSchemeService.CreateTestScheme(testVM.testSchemeName, testVM.testSchemeDescription, questionsIDs);
                testSchemeService.AddTestScheme(testTemplate);
                testSchemeService.AddTemplateQuestions(testSchemeService.GetQuestionListFromID(questionsIDs), testTemplate);

                return(RedirectToAction("Index", "Admin"));
            }

            return(RedirectToAction("Index", "Admin"));
        }
示例#10
0
        public void SetScore(int testID)
        {
            int                    score        = 0;
            int                    maxScore     = 0;
            Test                   test         = GetTest(testID);
            TestTemplate           testTemplate = _adminRepository.GetTestTemplate(test.testTemplateID);
            ICollection <Question> questions    = _adminRepository.GetQuestionsFromTemplate(testTemplate.testTemplateID);

            foreach (Question question in questions)
            {
                maxScore += question.points;
                if (_adminRepository.GetQuestionType(question.questionTypeID).typeName.ToLower() == "otwarte")
                {
                    foreach (GivenAnswer givenAnswer in _adminRepository.GetGivenAnswers(testID, question.questionID)) //co prawda w otwartym jest jedna odpowiedź, ale tak wyszło xd
                    {
                        score += givenAnswer.points;
                    }
                }
                else //pytanie jest jednokrotnego lub wielokrotnego wyboru
                {
                    bool isCorrect = true;
                    foreach (GivenAnswer givenAnswer in _adminRepository.GetGivenAnswers(testID, question.questionID))
                    {
                        if (!givenAnswer.isCorrect)
                        {
                            isCorrect = false;
                            break;
                        }
                    }
                    if (isCorrect)
                    {
                        score += question.points;
                    }
                }
            }

            int percentageScore = score * 100 / maxScore;

            UpdateTest(testID, percentageScore);
        }
        public void ResourceWithTags()
        {
            // Arrange
            var tags = new Dictionary <string, string>
            {
                { "key1", "value1" },
                { "key2", "value2" },
            };

            var resource = new TestResource()
                           .WithTags(tags);

            var template = new TestTemplate()
                           .WithResources(resource);

            // Act
            var result = template.ToJson(_options);

            // Assert
            var expected = @"{
              ""$schema"":""{DefaultTemplateSchema}"",
              ""contentVersion"":""{DefaultContentVersion}"",
              ""resources"": [
                {
                  ""type"": ""{DefaultResourceType}"",
                  ""apiVersion"": ""{DefaultApiVersion}"",
                  ""name"": """",
                  ""tags"": {
                    ""key1"": ""value1"",
                    ""key2"": ""value2""
                  },
                  ""properties"": {}
                }
              ],
              ""outputs"": {}
            }";

            JsonShouldBeEquivalent(expected, result);
        }
        public void ResourceWithLocalPropertiesSet()
        {
            // Arrange
            var resource = new TestResource("name", Location.UKSouth)
            {
                Kind = "kind",
                Sku  = new Sku {
                    Name = "name"
                },
            };

            var template = new TestTemplate()
                           .WithResources(resource);

            // Act
            var result = template.ToJson(_options);

            // Assert
            var expected = @"{
              ""$schema"":""{DefaultTemplateSchema}"",
              ""contentVersion"":""{DefaultContentVersion}"",
              ""resources"": [
                {
                  ""type"": ""{DefaultResourceType}"",
                  ""apiVersion"": ""{DefaultApiVersion}"",
                  ""name"": ""name"",
                  ""location"": ""uksouth"",
                  ""kind"": ""kind"",
                  ""sku"": {
                    ""name"": ""name"",
                  },
                  ""properties"": {}
                }
              ],
              ""outputs"": {}
            }";

            JsonShouldBeEquivalent(expected, result);
        }
示例#13
0
        public void MapToTestWizardHeaderDto_TestTemplate_ValidDto()
        {
            //arrange
            var testTemplateId = 36;
            var publishDate    = new DateTime(2021, 3, 23, 14, 23, 7, DateTimeKind.Utc);
            var testName       = "MyTest#1";
            var questionIds    = new int[] { 10, 11, 12 };
            var testTemplate   = new TestTemplate(testTemplateId, testName, 1, questionIds);

            var expectedDto = new Dtos.Wizard.TestTemplateHeaderDto
            {
                Id   = testTemplateId,
                Name = testName,
                NumberOfQuestions = questionIds.Length
            };

            //act
            var dto = mapper.MapToTestWizardHeaderDto(testTemplate);

            //assert
            dto.Should().BeEquivalentTo(expectedDto);
        }
示例#14
0
        public void Should_Delete_Level_On_Bind_To_Template()
        {
            var templateToBind = new TestTemplate
            {
                Id = 1
            };
            var testToBeBinded = new TestDTO()
            {
                TestTemplateId = 1,
                Levels         =
                {
                    new TestLevelDTO
                    {
                        TestTemplateLevelId = 3
                    }
                }
            };

            var testsRepositoryMock = new Mock <IRepository <Entities.Test> >();

            testsRepositoryMock.Setup(m => m.Filter(It.IsAny <Expression <Func <Entities.Test, bool> > >()))
            .Returns(new Entities.Test[0]);

            var templatesRepositoryMock = new Mock <IRepository <TestTemplate> >();

            templatesRepositoryMock.Setup(m => m.Get(1)).Returns(templateToBind);

            var unitOfWorkMock = new Mock <IUnitOfWork>();

            unitOfWorkMock.Setup(u => u.Tests).Returns(() => testsRepositoryMock.Object);
            unitOfWorkMock.Setup(u => u.TestTemplates).Returns(() => templatesRepositoryMock.Object);

            var service = new TestService(null, unitOfWorkMock.Object, mapper);

            service.BindToTemplate(testToBeBinded, 1);

            Assert.Single(testToBeBinded.Levels);
            Assert.True(testToBeBinded.Levels.Single().TemplateDeleted);
        }
示例#15
0
        /// <summary>
        ///     Populate a template that already has the TemplateId property determined.
        /// </summary>
        /// <param name="template">A completed TestTemplate.</param>
        internal static void LoadTemplateThatHasId(TestTemplate template)
        {
            SqlConnection conn = null;

            try
            {
                var sel = "up_LoadTestSettings";
                conn = TwisterConnection();

                SqlCommand cmd = CreateCommand(conn, sel);
                cmd.Parameters.Add(new SqlParameter
                {
                    ParameterName = "@templateId",
                    Value         = template.Id
                });

                using (SqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        template.Description            = dr["TestDescription"] as string;
                        template.ClockwiseTorque        = (int)dr["ClockwiseTorque"];
                        template.CounterclockwiseTorque = (int)dr["CounterclockwiseTorque"];
                        template.RunSpeed  = (int)dr["RunSpeed"];
                        template.MoveSpeed = (int)dr["MoveSpeed"];
                    }
                }

                cmd.Dispose();
            }
            catch (Exception ex)
            {
                Debug.WriteLine(Msg.GeneralExceptionMessage(ex, "SaveToDatabase"));
            }
            finally
            {
                CloseConnection(conn);
            }
        }
示例#16
0
        public void PatientVisitAdd()
        {
            PatientVisit visit = new PatientVisit();

            {
                visit.ExpectedDeliveryDate = new DateTime(2017, 02, 23);
                visit.ArriveDate           = DateTime.Now;
            };

            visit.Patient = new Patient();
            {
                visit.Patient.ContactNo = "0771013425";
                visit.Patient.Address   = "12/B,colombo09";
                visit.Patient.Name      = "navod perera";
                visit.Patient.Age       = 30;
                visit.Patient.Gender    = "M";
            };

            visit.Doctor = new Doctor();
            {
                visit.Doctor.DoctorName       = "Thilan perera";
                visit.Doctor.DoctorSpeciality = "ENT";
            };

            visit.User = new User();
            {
                visit.User.Username   = "******";
                visit.User.ModifiedBy = null;
            };

            TestTemplate template = new TestTemplate()
            {
                TemplateName = "Blood Report Template",
            };

            PatientVisitManager patientvisit = new PatientVisitManager();
            var Visit = patientvisit.AddNewPatientVisit(visit, template);
        }
        public IActionResult Post(TestTemplate testtemplate)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            using (var trans = context.Database.BeginTransaction())
            {
                try
                {
                    context.TestTemplates.Add(testtemplate);
                    context.SaveChanges();
                    trans.Commit();
                    return(Ok(testtemplate));
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    return(BadRequest(ex));
                }
            }
        }
示例#18
0
        public async Task ShouldNotDeleteQuestionUsedInTestTemplate()
        {
            var authorId      = fixture.UserId;
            var writtenAnswer = new WrittenAnswer("answer", 1f);
            var question      = new Question("Question?", writtenAnswer, authorId);

            await fixture.ExecuteDbContext(db =>
            {
                db.Questions.Add(question);
                return(db.SaveChangesAsync());
            });

            var testTemplate = new TestTemplate("new test template", authorId, new int[] { question.Id });
            await fixture.ExecuteDbContext(db =>
            {
                db.TestTemplates.Add(testTemplate);
                return(db.SaveChangesAsync());
            });

            var response = await fixture.RequestSender.DeleteAsync($"questions/{question.Id}");

            response.StatusCode.Should().Be(HttpStatusCode.BadRequest);
        }
示例#19
0
        public void AddArrayOutput_WithListOfValues_ShouldAddArrayOutputValueContainingListOfStringOutputValuesToOutputsProperty()
        {
            // Arrange
            var template = new TestTemplate();
            var key      = "key";
            var value    = "value";

            // Act
            template.AddArrayOutput(key, new List <string> {
                value
            });

            // Assert
            template.Outputs.Should().HaveCount(1);
            template.Outputs.First().Key.Should().Be(key);
            template.Outputs.First().Value.Should().BeOfType <ArrayOutputValue>();
            template.Outputs.First().Value.HasValue.Should().BeTrue();
            template.Outputs.First().Value.As <ArrayOutputValue>().Value.Should().BeOfType <List <OutputValue> >();
            template.Outputs.First()
            .Value.As <ArrayOutputValue>()
            .Value.First().As <StringOutputValue>()
            .Value.Should().Be(value);
        }
示例#20
0
        public void Generate_All()
        {
            Clean();
            EnsurePathsExist();

            var files = GetAllYamlFiles();

            var deser = new Deserializer();

            foreach (var file in files)
            {
                //if( !file.Contains("random", StringComparison.OrdinalIgnoreCase) )
                //    continue;//just deal with random for now.
                Console.WriteLine("READING: " + file);
                var sr       = new StringReader(File.ReadAllText(file));
                var yamlTest = deser.Deserialize <YamlTest>(sr);

                var mutator = new CSharpTestMutator(yamlTest);
                mutator.MutateTests();


                var outputFile =
                    Path.Combine(OutputDir,
                                 Path.GetFileName(
                                     Path.ChangeExtension(file, ".cs")));

                Console.WriteLine("OUTPUT: " + outputFile);

                var template = new TestTemplate()
                {
                    YamlTest = yamlTest
                };

                File.WriteAllText(outputFile, template.TransformText());
            }
        }
        public void ResourceWithDependencies()
        {
            // Arrange
            var dependency1 = new TestResource("dependency1");
            var dependency2 = new TestResource("dependency2");

            var resource = new TestResource()
                           .WithDependencies(new[] { dependency1, dependency2 });

            var template = new TestTemplate()
                           .WithResources(resource);

            // Act
            var result = template.ToJson(_options);

            // Assert
            var expected = @"{
              ""$schema"":""{DefaultTemplateSchema}"",
              ""contentVersion"":""{DefaultContentVersion}"",
              ""resources"": [
                {
                  ""type"": ""{DefaultResourceType}"",
                  ""apiVersion"": ""{DefaultApiVersion}"",
                  ""name"": """",
                  ""dependsOn"": [
                    ""[resourceId('{DefaultResourceType}', 'dependency1')]"",
                    ""[resourceId('{DefaultResourceType}', 'dependency2')]""
                  ],
                  ""properties"": {}
                }
              ],
              ""outputs"": {}
            }";

            JsonShouldBeEquivalent(expected, result);
        }
示例#22
0
 public void AddTemplateQuestions(List <Question> qList, TestTemplate testTemplate)
 {
     _adminRepository.AddQuestionsToTestScheme(qList.AsEnumerable(), testTemplate);
 }
示例#23
0
 public TestTemplate EditTestScheme(IEnumerable <Question> questions, TestTemplate testTemplate)
 {
     return(_adminRepository.EditTestTemplate(questions, testTemplate));
 }
示例#24
0
 public void AddQuestionsToTestScheme(IEnumerable <Question> questions, TestTemplate testTemplate)
 {
     _adminRepository.AddQuestionsToTestScheme(questions, testTemplate);
 }
示例#25
0
 public void AddTestScheme(TestTemplate testTemplate)
 {
     _adminRepository.AddTestTemplate(testTemplate);
 }
示例#26
0
        public void Derived_Email_sets_ViewName_from_class_name()
        {
            var email = new TestTemplate();

            email.ViewName.ShouldEqual("Test");
        }
示例#27
0
        public void Derived_Email_sets_ViewData_Model()
        {
            var email = new TestTemplate();

            email.ViewData.Model.ShouldBeSameAs(email);
        }
示例#28
0
        /// <summary>
        /// Sparsuje string na objekt triedy Request. dalsia akcia sa odvija od typu requestu
        /// </summary>
        /// <param name="message"></param>
        /// <returns> odpoved k danej poziadavke alebo null ak nie je poziadavka validna. Poziadavka bude zahodena</returns>
        public Response ProcessRequest(string message, string key)
        {
            Request  parsed_request = Request.ConvertToRequest(message);
            Response resp           = null;

            //neplatna ziadost
            if (parsed_request == null)
            {
                return(null);
            }

            switch (parsed_request.type)
            {
            case SERVICE_TYPE.DISCONNECT:
                resp = new Response(SERVICE_TYPE.DISCONNECT, "", RESULT_CODE.SUCCESS);
                //odhlasenie
                login_manager.LogOut(parsed_request.user.user_name);
                break;

            case SERVICE_TYPE.EVAL:
                //ak je uzivatel validny
                if (CheckAuthentification(parsed_request.user))
                {
                    ResultForm form = ResultForm.Convert(parsed_request.data);

                    //dummy vyhodnotenie
                }
                else
                {
                    resp = new Response(SERVICE_TYPE.EVAL, "", RESULT_CODE.PERM_DENIED);
                }
                break;

            case SERVICE_TYPE.GET:
                int id = 0;
                //dummy vratenie id
                TestTemplate test = TestManager.Instance().GetTest(id);
                // test nie je dostupny
                if (test == null)
                {
                    resp = new Response(SERVICE_TYPE.GET, "", RESULT_CODE.UNAVAILABLE);
                }
                else
                {
                    string data = test.ConvertTestToString();
                    if (data == null)
                    {
                        Console.Error.WriteLine("Error: data test");
                        data = "";
                    }
                    resp = new Response(SERVICE_TYPE.GET, data, RESULT_CODE.SUCCESS);
                }

                break;

            case SERVICE_TYPE.LOGIN:
                //spracovanie prijatych udajov
                Account     user = parsed_request.user;
                RESULT_CODE code;

                //prihlasenie bolo uspesne
                if (login_manager.LogIn(user.user_name, user.password_hash))
                {
                    //namapuj
                    login_manager.MapUser(key, user.user_name);
                    //nastav vysledok
                    code = RESULT_CODE.SUCCESS;
                }
                else
                {
                    code = RESULT_CODE.PERM_DENIED;
                }
                resp = new Response(SERVICE_TYPE.LOGIN, "", code);
                break;

            case SERVICE_TYPE.TESTS_LIST:
                //autentifikacia nepresla
                if (!CheckAuthentification(parsed_request.user))
                {
                    Console.WriteLine("Neautorizovane");
                    resp = new Response(SERVICE_TYPE.TESTS_LIST, "", RESULT_CODE.PERM_DENIED);
                }
                else
                {
                    string tests_list = TestManager.Instance().GetTestsNames();
                    resp = new Response(SERVICE_TYPE.TESTS_LIST, tests_list, RESULT_CODE.SUCCESS);
                }
                break;

            default:
                break;
            }
            return(resp);
        }
示例#29
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="patientVisit"></param>
        /// <param name="Template"></param>

        /// <returns></returns>
        public PatientVisitDto AddNewPatientVisit(PatientVisit patientVisit, TestTemplate Template)
        {
            PatientVisitHelper visithelp = new PatientVisitHelper();

            MapperConfig.ConfigAutoMapper();

            if (this.ValidateVisit(patientVisit))
            {
                patientVisit.CreatedDate  = DateTime.Now;
                patientVisit.CreatedBy    = "EMP";
                patientVisit.ModifiedDate = new DateTime(2017, 12, 2);
                patientVisit.ModifiedBy   = string.Empty;

                // if (DoctorRepository.GetDoctor(patientVisit.Doctor.DoctorId) == null)
                if (DoctorHelp.GetDoctorByName(patientVisit.Doctor.DoctorName) == null ||
                    DoctorHelp.GetDoctorBySpeciality(patientVisit.Doctor.DoctorSpeciality) == null)
                {
                    this.AddNewDoctor(patientVisit.Doctor);

                    System.Diagnostics.Debug.WriteLine("Doctor Added");

                    patientVisit.Doctor = DoctorHelp.GetDoctorByName(patientVisit.Doctor.DoctorName);
                }
                else
                {
                    patientVisit.DoctorID = DoctorHelp.GetDoctorByName(patientVisit.Doctor.DoctorName).DoctorId;

                    patientVisit.Doctor = DoctorHelp.GetDoctorByName(patientVisit.Doctor.DoctorName);

                    System.Diagnostics.Debug.WriteLine("Doctor Exists");
                }


                if (PatientRepository.GetPatient(patientVisit.Patient.ContactNo) == null)
                {
                    this.AddNewPatient(patientVisit.Patient);

                    patientVisit.Patient = PatientRepository.GetPatient(patientVisit.Patient.ContactNo);

                    System.Diagnostics.Debug.WriteLine("Patient Added");
                }
                else
                {
                    patientVisit.PatientID = PatientRepository.GetPatient(patientVisit.Patient.ContactNo).PatientId;

                    patientVisit.Patient = PatientRepository.GetPatient(patientVisit.Patient.ContactNo);

                    System.Diagnostics.Debug.WriteLine("Patient Exists");
                }

                patientVisit.UserId = UserRepository.GetUser(patientVisit.User.Username).UserId;

                patientVisit.User.RoleId = 1;

                patientVisit.User = UserRepository.GetUser(patientVisit.User.Username);

                var NewVisit = PatientVisitRepo.Insert(Mapper.Map <PatientVisit>(patientVisit));
                Mapper.Map <PatientVisitDto>(NewVisit);

                System.Diagnostics.Debug.WriteLine("Visit Added");

                int VisitId = NewVisit.PatientVisitId;

                this.AddNewPatientTest(VisitId, Template);

                System.Diagnostics.Debug.WriteLine("Patient Test Added");

                int testTemplateID = TestTemplateRepository.GetTestTemplate(Template.TemplateName).TestTemplateId;

                IList <TestTemplateAttributeDto> TestAttribute = visithelp.GetTestTemplateAttributes(testTemplateID);

                TestResult results = new TestResult();

                foreach (var x in TestAttribute)
                {
                    results.AttrID  = x.AttrID;
                    results.VisitID = VisitId;
                    results.Status  = "NO STATUS YET";
                    results.Value   = "NO VALUE YET";
                    this.AddNewTestResult(results);
                }

                System.Diagnostics.Debug.WriteLine("Result Added");
            }

            else
            {
                throw new ArgumentNullException("Provided information is not valid.");
            }

            return(null);
        }
        public void ResourceWithProperties()
        {
            // Arrange
            var resource = new TestResource
            {
                Properties = new TestProperties
                {
                    BoolProp = true,
                    InfoProp = new TestInfo
                    {
                        BoolProp   = true,
                        IntProp    = 0,
                        StringProp = "value",
                    },
                    IntProp        = 0,
                    ListStringProp = new List <string> {
                        "value1", "value2"
                    },
                    ListInfoProp = new List <TestInfo>
                    {
                        new TestInfo {
                            StringProp = "value1"
                        },
                        new TestInfo {
                            StringProp = "value2"
                        },
                    },
                    StringProp = "value",
                },
            };

            var template = new TestTemplate()
                           .WithResources(resource);

            // Act
            var result = template.ToJson(_options);

            // Assert
            var expected = @"{
              ""$schema"":""{DefaultTemplateSchema}"",
              ""contentVersion"":""{DefaultContentVersion}"",
              ""resources"": [
                {
                  ""type"": ""{DefaultResourceType}"",
                  ""apiVersion"": ""{DefaultApiVersion}"",
                  ""name"": """",
                  ""properties"": {
                    ""boolProp"": true,
                    ""infoProp"": {
                      ""boolProp"": true,
                      ""intProp"": 0,
                      ""stringProp"": ""value""
                    },
                    ""intProp"": 0,
                    ""listStringProp"": [
                      ""value1"",
                      ""value2""
                    ],
                    ""listInfoProp"": [
                      {
                        ""stringProp"": ""value1""
                      },
                      {
                        ""stringProp"": ""value2""
                      }
                    ],
                    ""stringProp"": ""value""
                  },
                }
              ],
              ""outputs"": {}
            }";

            JsonShouldBeEquivalent(expected, result);
        }
示例#31
0
 public DetailsWindow(TestTemplate temp)
 {
     InitializeComponent();
 }
示例#32
0
 public void Derived_Email_sets_ViewName_from_class_name()
 {
     var email = new TestTemplate();
     email.ViewName.ShouldEqual("Test");
 }
示例#33
0
 public void Derived_Email_sets_ViewData_Model()
 {
     var email = new TestTemplate();
     email.ViewData.Model.ShouldBeSameAs(email);
 }
示例#34
0
        public static void PrintResults()
        {
            TestTemplate template = new TestTemplate(outResults);

            outResults.Clear();
        }
示例#35
0
 public void AddTestTemplate(TestTemplate entity)
 {
     db.testTemplates.Add(entity);
     SaveChanges();
 }
示例#36
0
文件: Test.cs 项目: gahadzikwa/GAPP
 public static string Run(Plugin plugin, ICore core)
 {
     TestTemplate instance = new TestTemplate();
     return instance.RunInstance(plugin, core);
 }