Пример #1
0
        public void temp_controller_get_all_temps_of_date()
        {
            var tempController = new TempController(_dbConnectionString);

            var addEntity = new TempModel
            {
                Id       = 1,
                Value    = 1f,
                DateTime = new DateTime(2018, 12, 1, 12, 0, 0)
            };
            var addSuccess = tempController.AddTemp(addEntity);

            Assert.IsTrue(addSuccess);

            var addEntity2 = new TempModel
            {
                Id       = 2,
                Value    = 2f,
                DateTime = new DateTime(2019, 12, 1, 12, 0, 0)
            };

            addSuccess = tempController.AddTemp(addEntity2);
            Assert.IsTrue(addSuccess);

            var addEntity3 = new TempModel
            {
                Id       = 3,
                Value    = 3f,
                DateTime = new DateTime(2019, 12, 1, 18, 0, 0)
            };

            addSuccess = tempController.AddTemp(addEntity3);
            Assert.IsTrue(addSuccess);

            var temps = tempController.GetTempsByDate(new DateTime(2019, 12, 1)).ToArray();

            Assert.IsNotNull(temps);
            Assert.AreEqual(2, temps.Length);

            Assert.AreEqual(addEntity3.Id, temps[0].Id);
            Assert.AreEqual(addEntity3.DateTime, temps[0].DateTime);
            Assert.AreEqual(addEntity3.Value, temps[0].Value);
            Assert.AreEqual(addEntity2.Id, temps[1].Id);
            Assert.AreEqual(addEntity2.DateTime, temps[1].DateTime);
            Assert.AreEqual(addEntity2.Value, temps[1].Value);

            Assert.IsTrue(tempController.RemoveTemp((int)addEntity.Id));
            Assert.IsTrue(tempController.RemoveTemp((int)addEntity2.Id));
            Assert.IsTrue(tempController.RemoveTemp((int)addEntity3.Id));
        }