コード例 #1
0
        public void DataAccessImplementationIsDerivedFromIDataAccess()
        {
            IDataAccess dal = new DataAccessImplementation() as IDataAccess;

            Assert.IsNotNull(dal,
                             $"DataAccessLayerTests - Class \"DataAccessImplementation\" does not implement interface \"IDataAccess\"!");
        }
コード例 #2
0
        public void TestClearData()
        {
            const int distance1 = 1000;
            var       interval1 = new TimeSpan(0, 6, 0);
            var       da        = new DataAccessImplementation();
            var       date      = DateTime.Now - new TimeSpan(5, 0, 0, 0);

            da.StoreRunInfo(date, new RunInfo(distance1, interval1));

            var info = da.GetRunInfoForDate(date);

            Assert.IsNotNull(info, $"DataAccessLayerTests - \"GetRunInfoForDate\" returns null for date with stored info!");
            Assert.IsTrue((info.DistanceInMeter == distance1), $"DataAccessLayerTests - \"GetRunInfoForDate\" returns wrong distance: was {info.DistanceInMeter}, expected {distance1}!");
            Assert.IsTrue((info.Interval == interval1), $"DataAccessLayerTests - \"GetRunInfoForDate\" returns wrong interval: was {info.Interval.ToString()}, expected {interval1.ToString()}!");

            da.ClearData();
            info = da.GetRunInfoForDate(date);
            Assert.IsNotNull(info, $"DataAccessLayerTests - \"GetRunInfoForDate\" returns null after call to \"ClearData\"!");
            Assert.IsTrue((info.DistanceInMeter == 0), $"DataAccessLayerTests - \"GetRunInfoForDate\" returns wrong distance after call to \"ClearData\": was {info.DistanceInMeter}, expected {0}!");
            Assert.IsTrue((info.Interval == new TimeSpan(0, 0, 0)), $"DataAccessLayerTests - \"GetRunInfoForDate\" returns wrong interval after call to \"ClearData\": was {info.Interval.ToString()}, expected {new TimeSpan(0, 0, 0).ToString()}!");


            da   = new DataAccessImplementation();
            info = da.GetRunInfoForDate(date);
            Assert.IsNotNull(info, $"DataAccessLayerTests - \"GetRunInfoForDate\" returns null after call to \"ClearData\" & restart!");
            Assert.IsTrue((info.DistanceInMeter == 0), $"DataAccessLayerTests - \"ClearData\" does not clear distance data on disk!");
            Assert.IsTrue((info.Interval == new TimeSpan(0, 0, 0)), $"DataAccessLayerTests - \"ClearData\" does not clear instance data on disk!!");
        }
コード例 #3
0
        static void Main()
        {
            DataAccessImplementation dataAcces = new DataAccessImplementation();
            LogicImplementation      logic     = new LogicImplementation(dataAcces);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm(logic));
        }
コード例 #4
0
        public void NonexistingDatereturnsDefaultValue()
        {
            var da   = new DataAccessImplementation();
            var info = da.GetRunInfoForDate(DateTime.Now.Date + new TimeSpan(3000, 0, 0, 0));

            Assert.IsNotNull(info, $"DataAccessLayerTests - \"GetRunInfoForDate\" returns null for date without info (should be default value)!");
            Assert.IsTrue((info.DistanceInMeter == 0), $"DataAccessLayerTests - \"GetRunInfoForDate\" does not return zero distance for date without info!");
            Assert.IsTrue((info.Interval == new TimeSpan(0, 0, 0)), $"DataAccessLayerTests - \"GetRunInfoForDate\" does not return zero interval for date without info!");
        }
コード例 #5
0
        public void StoreAndRetrieveRunInfos()
        {
            const int distance1 = 1000;
            var       interval1 = new TimeSpan(0, 6, 0);
            var       da        = new DataAccessImplementation();
            var       date      = DateTime.Now - new TimeSpan(5, 0, 0, 0);

            da.StoreRunInfo(date, new RunInfo(distance1, interval1));

            var info = da.GetRunInfoForDate(date);

            Assert.IsNotNull(info, $"DataAccessLayerTests - \"GetRunInfoForDate\" returns null for date with stored info!");
            Assert.IsTrue((info.DistanceInMeter == distance1), $"DataAccessLayerTests - \"GetRunInfoForDate\" returns wrong distance: was {info.DistanceInMeter}, expected {distance1}!");
            Assert.IsTrue((info.Interval == interval1), $"DataAccessLayerTests - \"GetRunInfoForDate\" returns wrong interval: was {info.Interval.ToString()}, expected {interval1.ToString()}!");
        }
コード例 #6
0
        public void OverWriteRunInfo()
        {
            const int distance1 = 1000;
            var       interval1 = new TimeSpan(0, 6, 0);
            const int distance2 = 2000;
            var       interval2 = new TimeSpan(0, 15, 0);
            var       da        = new DataAccessImplementation();
            var       date      = DateTime.Now - new TimeSpan(5, 0, 0, 0);

            try
            {
                da.StoreRunInfo(date, new RunInfo(distance1, interval1));
                da.StoreRunInfo(date, new RunInfo(distance2, interval2));
            }
            catch (Exception e)
            {
                Assert.Fail($"DataAccessLayerTests - OverWriteRunInfo: storing new info for existing date throws exception: {e.Message} ");
            }
            var info = da.GetRunInfoForDate(date);

            Assert.IsNotNull(info, $"DataAccessLayerTests - \"GetRunInfoForDate\" returns null for date with stored info!");
            Assert.IsTrue((info.DistanceInMeter == distance2), $"DataAccessLayerTests - \"GetRunInfoForDate\" returns wrong distance after overwrite: was {info.DistanceInMeter}, expected {distance2}!");
            Assert.IsTrue((info.Interval == interval2), $"DataAccessLayerTests - \"GetRunInfoForDate\" returns wrong interval after overwrite: was {info.Interval.ToString()}, expected {interval2.ToString()}!");
        }