static void Main(string[] args) { var db = new DataBaseMicrosoft(SolutionConfiguration.DatabaseType, SolutionConfiguration.DatabaseArguments); var groups = db.GetElements<Group>(); foreach (var group in groups) { db.FillElement(group); } var maxLengthPeople = groups.Max(group => group.Peoples.Max(people => people.Name.Length)); var maxLengthGroup = groups.Max(group => group.Name.Length); var tab = "\t\t"; var report = new StringBuilder(); report.Append($"{"Тестируемый".ModifyToTotalLength(maxLengthPeople)}{tab}{"Группа".ModifyToTotalLength(maxLengthGroup)}{tab}Пароль\n\n"); foreach (var group in groups) { foreach (var people in group.Peoples) { report.Append($"{people.Name.ModifyToTotalLength(maxLengthPeople)}{tab}{group.Name.ModifyToTotalLength(maxLengthGroup)}{tab}{people.Password}\n"); } report.Append("\n"); } File.WriteAllText("Passwords.txt", report.ToString()); System.Diagnostics.Process.Start("Passwords.txt"); }
public void ShouldInsertTests() { // Given var db = new DataBaseMicrosoft(DataBasesTypes.MicrosoftAccess, TestHelper.CreateTempFile()); var test = new Test("Пробный Тест", 70); var questions = new[] { new Question("Вопрос 1"), new Question("Вопрос 2") }; var expected = new[] { new Test("Первый тест", 100), new Test("Пробный Тест", 70) }; // When test.SetQuestions(questions); test.SetComponent(new Component("", 1)); questions[0].SetAssessments(new Assessments()); questions[1].SetAssessments(new Assessments()); var status = db.ExecuteCommand(Parameters.Insert, test); var actual = db.GetElements<Test>(); db.FillElement(actual[1]); TestHelper.DeleteTemp(); // Then Assert.AreEqual(0, status.ExitCode); Assert.IsNull(status.ErrorMessage); Assert.AreEqual(expected.Length, actual.Length); Assert.IsInstanceOf<Test>(actual[0]); CollectionAssert.AreEqual(expected, actual); CollectionAssert.AreEqual(questions, actual[1].Questions); }
public void ShouldInsertComponent() { // Given var db = new DataBaseMicrosoft(DataBasesTypes.MicrosoftAccess, TestHelper.CreateTempFile()); var generalComponents = new[] { new Component("ОбщийКомпонент№1"), new Component("ОбщийКомпонент№2"), new Component("ОбщийКомпонент№3") }; var component = new Component("Компонент1Уровня") { Components = { new Component("Компонент2Уровня№1") { Components = { new Component("Компонент3Уровня№1") { Components = { generalComponents[0], generalComponents[1], generalComponents[2] } }, new Component("Компонент3Уровня№2") { Components = { generalComponents[0], generalComponents[1], generalComponents[2] } } } } } }; // When db.ExecuteCommand(Parameters.Insert, component); var actual = db.GetElements<Component>().Last(); db.FillElement(actual); TestHelper.DeleteTemp(); // Then // Top Level Assert.AreEqual(component, actual); // 2 Level Assert.AreEqual(component.Components[0], actual.Components[0]); // 3 Level Assert.AreEqual(component.Components[0].Components[0], actual.Components[0].Components[0]); Assert.AreEqual(component.Components[0].Components[1], actual.Components[0].Components[1]); // General Assert.AreEqual(component.Components[0].Components[0].Components[0], actual.Components[0].Components[0].Components[0]); Assert.AreEqual(component.Components[0].Components[0].Components[1], actual.Components[0].Components[0].Components[1]); Assert.AreEqual(component.Components[0].Components[0].Components[2], actual.Components[0].Components[0].Components[2]); Assert.AreEqual(component.Components[0].Components[1].Components[0], actual.Components[0].Components[1].Components[0]); Assert.AreEqual(component.Components[0].Components[1].Components[1], actual.Components[0].Components[1].Components[1]); Assert.AreEqual(component.Components[0].Components[1].Components[2], actual.Components[0].Components[1].Components[2]); }