Commit 00e5d96b authored by Alexandre Meyer's avatar Alexandre Meyer

Mon Mini TP sur les erreurs de nommage qui amène de la désinformation

parents
using SPAM;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Test
{
public static class DataGenerator
{
public static XMLLoad GenerateTestXMLAndReplaceString(string StringToReplace, string StringSubstitute)
{
String XMLTestFileName = "FichierDeTest.xml";
using (StreamWriter fileTestStreamWriter =
new StreamWriter(XMLTestFileName))
{
fileTestStreamWriter.WriteLine(GenerateXML().Replace(matchString, changeString));
}
XMLLoad Testxml = new XMLLoad(XMLTestFileName);
return Testxml;
}
public static Memory GenerateMemoryFromADate(DateTime userdate)
{
Memory GeneratedMemoryFromADate = new Memory();
List<string> emailsList = new List<string> { "testEmail@soat.fr", "testEmail2@soat.fr" };
LastMailingSendInfo LastInformations = new LastMailingSendInfo("TestXMLLoad", emailsList, userdate);
GeneratedMemoryFromADate.MyMemoryMailingValue.Add(LastInformations.Name, LastInformations);
return GeneratedMemoryFromADate;
}
public static DateTime GenerateFirstDayOfCurrentMonthOrFirstDayOfMonthBefore()
{
DateTime DateOfNowOrYesterday = (DateTime.Now.Day == 1) ? DateTime.Now.AddDays(-1) : DateTime.Now;
DateTime FirstDayOfCurrentBeforeToday = new DateTime(DateOfNowOrYesterday.Year, DateOfNowOrYesterday.Month, 1);
return FirstDayOfCurrentBeforeToday;
}
}
}
using SPAM;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Test
{
public static class DataGenerator
{
private static string GenerateXML()
{
StringBuilder data = new StringBuilder();
data.AppendLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
data.AppendLine("<mailings>");
data.AppendLine("<mailing nom=\"TestXMLLoad\">");
data.AppendLine("<summary>Test du XML Load</summary>");
data.AppendLine("<location>Salle OQP</location>");
data.AppendLine("<description>Xml de test générer a la volé</description>");
data.AppendLine("<days>");
data.AppendLine("<day>0</day>");
//data.AppendLine("<day>2</day>");
//data.AppendLine("<day>4</day>");
data.AppendLine("</days>");
data.AppendLine("<startHour>10</startHour>");
data.AppendLine("<duration>15</duration>");
data.AppendLine("<attendees>");
data.AppendLine("<emails>");
data.AppendLine("<email>");
data.AppendLine("<value>testEmail@soat.fr</value>");
data.AppendLine("<name>Prenom Nom</name>");
data.AppendLine("<dir>INT</dir>");
data.AppendLine("<dispos>");
data.AppendLine("<day>0</day>");
data.AppendLine("<day>2</day>");
data.AppendLine("<day>4</day>");
data.AppendLine("</dispos>");
data.AppendLine("</email>");
data.AppendLine("<email>");
data.AppendLine("<value>testEmail2@soat.fr</value>");
data.AppendLine("<name>Prenom2 Nom2</name>");
data.AppendLine("<dir>DSI</dir>");
data.AppendLine("<dispos>");
data.AppendLine("<day>0</day>");
data.AppendLine("<day>1</day>");
data.AppendLine("<day>2</day>");
data.AppendLine("<day>3</day>");
data.AppendLine("<day>4</day>");
data.AppendLine("</dispos>");
data.AppendLine("</email>");
data.AppendLine("</emails>");
data.AppendLine("</attendees>");
data.AppendLine("<type>Week</type>");
data.AppendLine("</mailing>");
data.AppendLine("</mailings>");
return data.ToString();
}
public static XMLLoad GenerateXMLLoad(string matchString, string changeString)
{
String FileName = "FichierDeTest.xml";
using (StreamWriter file =
new StreamWriter(FileName))
{
file.WriteLine(GenerateXML().Replace(matchString, changeString));
}
XMLLoad xml = new XMLLoad(FileName);
return xml;
}
public static Memory GenerateMemory(DateTime date)
{
Memory result = new Memory();
List<string> email = new List<string> { "testEmail@soat.fr", "testEmail2@soat.fr" };
LastMailingSendInfo lmsi = new LastMailingSendInfo("TestXMLLoad", email, date);
result.MyMemoryMailingValue.Add(lmsi.Name, lmsi);
return result;
}
public static DateTime GenerateFirstMonthDayBeforToday()
{
DateTime result = (DateTime.Now.Day == 1) ? DateTime.Now.AddDays(-1) : DateTime.Now;
result = new DateTime(result.Year, result.Month, 1);
return result;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SPAM
{
public class LastMailingSendInfo
{
public DateTime SentDate { get; }
public List<string> Emails { get; }
public string Name { get; }
public LastMailingSendInfo(string _name, List<string> _emails, DateTime _SentDate)
{
Emails = _emails;
Name = _name;
SentDate = _SentDate.Date;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SPAM
{
public class LastMailingSendInfo
{
public DateTime Date { get; }
public List<string> Email { get; }
public string Name { get; }
public LastMailingSendInfo(string name, List<string> email, DateTime date)
{
Email = email;
Name = name;
Date = date.Date;
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment