예제 #1
0
        public void Save(Template template)
        {
            const string query = "INSERT INTO Template (Template, Name) VALUES(@Template, @Name)";
            var command = new SqlCommand(query);

            PrepareStatement(command, template);
        }
예제 #2
0
 public Analysis(Template template, Person person)
 {
     _data = new Dictionary<string, string>();
     Template = template;
     Person = person;
     CreationTime = DateTime.Now;
 }
예제 #3
0
        public void Remove(Template template)
        {
            const string query = "DELETE FROM Analysis WHERE TemplateName=@TemplateName";
            var command = new SqlCommand(query);

            command.Parameters.Add("@TemplateName", SqlDbType.NVarChar);
            command.Parameters["@TemplateName"].Value = template.Name;

            _databaseProvider.PushData(command);
        }
예제 #4
0
        public void Analysis_ToAndFromJson_AnalysisIsProperlyDeserialized(string firstName, string lastName,
            string middleName, string birthDate)
        {
            var template = new Template("имя шаблона", "содержимое");
            var person = new Person(firstName, lastName, middleName, DateTime.Parse(birthDate));
            var jsonFormatter = new JsonFormatter();
            var expectedAnalysis = new Analysis(template, person);
            var actualAnalysis = jsonFormatter.FromJson<Analysis>(jsonFormatter.ToJson(expectedAnalysis));

            Assert.True(AnalyzesAreEqual(expectedAnalysis, actualAnalysis));
        }
예제 #5
0
        public void AnalysisProvider_PersonAnalyzesArePropelyLoaded_ShouldPass(string firstName, string lastName, string middleName, string birthDate)
        {
            var person = new Person(firstName, lastName, middleName, DateTime.Parse(birthDate));
            _personProvider.Save(ref person);

            var template = new Template("name" + firstName, "content");
            _templateProvider.Save(template);

            var expectedAnalysis = new Analysis(template, person);
            _analysisProvider.Save(ref expectedAnalysis);

            var analyzes = _analysisProvider.Load(person);

            _analysisProvider.Remove(expectedAnalysis);
            _personProvider.Remove(person);
            _templateProvider.Remove(template);

            var actualAnalysis = analyzes[0];

            Assert.True(analyzes.Count() == 1);
            Assert.True(AnalyzesAreEqual(expectedAnalysis, actualAnalysis));
        }
예제 #6
0
 private bool TemplatesAreEqual(Template first, Template second)
 {
     return first.Name.Equals(second.Name) &&
            first.HtmlTemplate.Equals(second.HtmlTemplate);
 }
예제 #7
0
        public void TemplateProvider_PersonAnalyzesArePropelyLoaded_ShouldPass(string name, string content)
        {
            var expectedTemplate = new Template(name, content);
            _templateProvider.Save(expectedTemplate);
            var templates = _templateProvider.Load();
            _templateProvider.Remove(expectedTemplate);

            var actualTemplate = templates[0];

            Assert.True(TemplatesAreEqual(expectedTemplate, actualTemplate));
        }
예제 #8
0
        public void Update(Template template)
        {
            const string query = "UPDATE Template SET Template=@Template WHERE Name=@Name";
             var command = new SqlCommand(query);

            PrepareStatement(command,template);
        }
예제 #9
0
        private void PrepareStatement(SqlCommand command, Template template)
        {
            command.Parameters.Add("@Template", SqlDbType.NText);
            command.Parameters["@Template"].Value = template.HtmlTemplate;

            command.Parameters.Add("@Name", SqlDbType.NVarChar);
            command.Parameters["@Name"].Value = template.Name;

            _databaseProvider.PushData(command);
        }
예제 #10
0
 internal Analysis(Template template, Person person, int id)
     : this(template, person)
 {
     Id = id;
 }