public void Save(Template template) { const string query = "INSERT INTO Template (Template, Name) VALUES(@Template, @Name)"; var command = new SqlCommand(query); PrepareStatement(command, template); }
public Analysis(Template template, Person person) { _data = new Dictionary<string, string>(); Template = template; Person = person; CreationTime = DateTime.Now; }
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); }
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)); }
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)); }
private bool TemplatesAreEqual(Template first, Template second) { return first.Name.Equals(second.Name) && first.HtmlTemplate.Equals(second.HtmlTemplate); }
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)); }
public void Update(Template template) { const string query = "UPDATE Template SET Template=@Template WHERE Name=@Name"; var command = new SqlCommand(query); PrepareStatement(command,template); }
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); }
internal Analysis(Template template, Person person, int id) : this(template, person) { Id = id; }