コード例 #1
0
        public void TestSetRunInfoBusinessRules()
        {
            var dal   = new DummyDal();
            var logic = new LogicImplementation(dal);
            var date  = DateTime.Now.Date;

            try
            {
                var info = new RunInfo(-5, new TimeSpan(3210));
                logic.SetRunInfoForDate(date, info);
                Assert.Fail($"LogicLayerTests - \"SetRunInfoForDate\" does not throw ArgumentOutOfRangeException for negative distance!");
            }
            catch (ArgumentOutOfRangeException e)
            {
                // this is expected, no problem
            }
            catch (AssertFailedException e)
            {
                throw e;
            }
            catch (Exception e)
            {
                Assert.Fail($"LogicLayerTests - \"SetRunInfoForDate\" with negative distance throws {e.GetType().Name} instead of ArgumentOutOfRangeException !");
            }

            try
            {
                var info = new RunInfo(130, new TimeSpan(0, 0, 9));
                logic.SetRunInfoForDate(date, info);
                Assert.Fail($"LogicLayerTests - \"SetRunInfoForDate\" does not throw ArgumentOutOfRangeException for speed in excess of 50km/h!");
            }
            catch (ArgumentOutOfRangeException e)
            {
                // this is expected, no problem
            }
            catch (AssertFailedException e)
            {
                throw e;
            }
            catch (Exception e)
            {
                Assert.Fail($"LogicLayerTests - \"SetRunInfoForDate\" with speed in excess of 50km/h throws {e.GetType().Name} instead of ArgumentOutOfRangeException !");
            }
        }
コード例 #2
0
        public void TestLogicOmitsTimeFromDate()
        {
            var dal   = new DummyDal();
            var logic = new LogicImplementation(dal);
            var date  = new DateTime(1234, 5, 6, 12, 12, 12);
            var info  = new RunInfo(321, new TimeSpan(0, 15, 30));

            logic.SetRunInfoForDate(date, info);
            Assert.IsTrue((date.Date == dal.RequestedDate),
                          $"LogicLayerTests - \"SetRunInfoForDate\" does not omit time info from Date when passing on to data access implementation !");
            info = logic.GetRunInfoForDate(date);
            Assert.IsTrue((date.Date == dal.RequestedDate),
                          $"LogicLayerTests - \"SetRunInfoForDate\" does not omit time info from Date when passing on to data access implementation !");
        }
コード例 #3
0
        public void TestSetRunInfoForDate()
        {
            var dal   = new DummyDal();
            var logic = new LogicImplementation(dal);
            var date  = new DateTime(1234, 5, 6);
            var info  = new RunInfo(321, new TimeSpan(0, 15, 30));

            logic.SetRunInfoForDate(date, info);

            Assert.IsTrue((dal.StoreRunInfoCalled),
                          $"LogicLayerTests - \"SetRunInfoForDate\" does not call corresponding method from data access implementation!");
            Assert.IsTrue((info.IsEqual(dal.StoredInfo)),
                          $"LogicLayerTests - \"SetRunInfoForDate\" does not pass RunInfo correctly to data access implementation !");
            Assert.IsTrue((date == dal.RequestedDate),
                          $"LogicLayerTests - \"SetRunInfoForDate\" does not pass date correctly to data access implementation !");
        }