Beispiel #1
0
        public async Task AddSittingTest_Success()
        {
            try
            {
                var deleteQuery = "delete from Sittings";
                RemoteQueryDatabase(deleteQuery);
                var selectQuery = "select * from Sittings";
                var result      = RemoteQueryDatabase(selectQuery);
                Assert.AreEqual(0, result.Rows.Count);

                await _service.AddSittings();

                result = RemoteQueryDatabase(selectQuery);

                //Should be three records in database
                Assert.AreEqual(3, result.Rows.Count);

                //Check details of the records
                Assert.AreEqual("1/01/2020 7:00:00 AM", result.Rows[0].ItemArray[1].ToString());
                Assert.AreEqual("1/01/2020 11:00:00 AM", result.Rows[0].ItemArray[2].ToString());
                Assert.AreEqual(15, (int)result.Rows[0].ItemArray[3]);
                Assert.AreEqual(0, (int)result.Rows[0].ItemArray[4]);

                Assert.AreEqual("1/01/2020 11:00:00 AM", result.Rows[1].ItemArray[1].ToString());
                Assert.AreEqual("1/01/2020 4:00:00 PM", result.Rows[1].ItemArray[2].ToString());
                Assert.AreEqual(15, (int)result.Rows[1].ItemArray[3]);
                Assert.AreEqual(1, (int)result.Rows[1].ItemArray[4]);

                Assert.AreEqual("1/01/2020 4:00:00 PM", result.Rows[2].ItemArray[1].ToString());
                Assert.AreEqual("1/01/2020 11:00:00 PM", result.Rows[2].ItemArray[2].ToString());
                Assert.AreEqual(15, (int)result.Rows[2].ItemArray[3]);
                Assert.AreEqual(2, (int)result.Rows[2].ItemArray[4]);
            }
            catch (Exception ex)
            {
                _logger.Error(ex.Message);
                throw new Exception(ex.Message);
            }
        }
        public async Task <IActionResult> Create()
        {
            await _service.AddSittings();

            return(View());
        }