Ejemplo n.º 1
0
        static async Task Main(string[] args)
        {
            var host = CreateHost();

            using (var serviceScope = host.Services.CreateScope())
            {
                var services = serviceScope.ServiceProvider;
                try
                {
                    var studentsSource = services.GetRequiredService <IStudentsSource>();
                    var studentDtos    = await studentsSource.GetStudentsAsync();

                    var students = studentDtos.Select(x => x.ToEntity()).ToList();
                    var report   = StudentsReport.Create("Maksym Voloshyn", "*****@*****.**", students);

                    var outputReportService = services.GetRequiredService <IOutputReportService>();
                    var outputReportTask    = outputReportService.OutputAsync(report);

                    var publishService = services.GetRequiredService <IStudentsReportPublishService>();
                    var publishTask    = publishService.PublishAsync(report);

                    await Task.WhenAll(outputReportTask, publishTask);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }

            Console.ReadLine();
        }
Ejemplo n.º 2
0
        public void Should_CreateStudentsReport()
        {
            //Arrange
            const string name  = "MyName";
            const string email = "MyEmail";

            //Act
            var orderedStudents = StudentsReport.Create(name, email, _fixture.Students);

            //Assert
            Assert.Equal(name, orderedStudents.YourName);
            Assert.Equal(email, orderedStudents.YourEmail);
            Assert.Equal(2013, orderedStudents.YearWithHighestAttendance);
            //TODO: Setup bigger test fixture to test TOP10 property
            Assert.Equal(2016, orderedStudents.YearWithHighestOverallGPA);
            Assert.Equal(3, orderedStudents.StudentIdMostInconsistent);
        }