Пример #1
0
        public async Task GetLastAddedShouldReturnLastItem()
        {
            //Arrange

            var ser = new SemestersServiceTest();

            //Act
            ser.Clear();
            await ser.Create(new Semester()
            {
                Name      = "Semester 1",
                StartDate = DateTime.UtcNow.ToString("yyyy-MM-dd"),
                EndDate   = DateTime.UtcNow.ToString("yyyy-MM-dd"),
            });

            await ser.Create(new Semester()
            {
                Name      = "Semester 2",
                StartDate = DateTime.UtcNow.AddDays(15).ToString("yyyy-MM-dd"),
                EndDate   = DateTime.UtcNow.AddDays(30).ToString("yyyy-MM-dd"),
            });

            var item = ser.GetLastAddedSemester();

            //Assert

            Assert.AreEqual("Semester 2", item.Name);
            Assert.AreEqual(DateTime.UtcNow.AddDays(15).ToString("yyyy-MM-dd"), item.StartDate);
            Assert.AreEqual(DateTime.UtcNow.AddDays(30).ToString("yyyy-MM-dd"), item.EndDate);
        }
Пример #2
0
        public async Task InsertShouldReturnOneItem()
        {
            //Arrange

            var ser = new SemestersServiceTest();

            //Act
            ser.Clear();
            await ser.Create(new Semester()
            {
                Name      = "Semester 1",
                StartDate = DateTime.UtcNow.ToString("yyyy-MM-dd"),
                EndDate   = DateTime.UtcNow.ToString("yyyy-MM-dd"),
            });

            var items = await ser.GetAllSemesters();

            var count = items.Count;

            //Assert

            Assert.AreEqual(1, count);
        }