﻿using Machine.Specifications;
using System;
using X3Code.Utilities.Extensions;

#region Disable ReSharper Warnings

// ReSharper disable ArrangeTypeMemberModifiers
// ReSharper disable UnusedMember.Local
// ReSharper disable UnusedMember.Global
// ReSharper disable InconsistentNaming

#endregion

#pragma warning disable 0169

namespace UnitTests.UtilitiesTests.Extensions
{
    [Subject("DateTime Extension")]
    public class Falls_bestimmte_Datumswerte_benötigt_werden
    {
        private static DateTime _30Januar2017;
        private static DateTime _nextMonday;
        private static DateTime _nextTuesday;
        private static DateTime _nextWednesday;
        private static DateTime _nextTursday;
        private static DateTime _nextFriday;
        private static DateTime _nextSaturday;
        private static DateTime _nextSunday;

        Establish context = () => _30Januar2017 = new DateTime(2017, 1, 30);

        Because of = () =>
        {
            _nextMonday = _30Januar2017.GetNextMonday();
            _nextTuesday = _30Januar2017.GetNextTuesday();
            _nextWednesday = _30Januar2017.GetNextWednesday();
            _nextTursday = _30Januar2017.GetNextThursday();
            _nextFriday = _30Januar2017.GetNextFriday();
            _nextSaturday = _30Januar2017.GetNextSaturday();
            _nextSunday = _30Januar2017.GetNextSunday();
        };

        It soll_das_Datum_dem_nächsten_Montag_entsprechen = () => _nextMonday.ShouldEqual(new DateTime(2017, 1, 30));
        It soll_das_Datum_dem_nächsten_Dienstag_entsprechen = () => _nextTuesday.ShouldEqual(new DateTime(2017, 1, 31));
        It soll_das_Datum_dem_nächsten_Mittwoch_entsprechen = () => _nextWednesday.ShouldEqual(new DateTime(2017, 2, 1));
        It soll_das_Datum_dem_nächsten_Donnerstag_entsprechen = () => _nextTursday.ShouldEqual(new DateTime(2017, 2, 2));
        It soll_das_Datum_dem_nächsten_Freitag_entsprechen = () => _nextFriday.ShouldEqual(new DateTime(2017, 2, 3));
        It soll_das_Datum_dem_nächsten_Samstag_entsprechen = () => _nextSaturday.ShouldEqual(new DateTime(2017, 2, 4));
        It soll_das_Datum_dem_nächsten_Sonntag_entsprechen = () => _nextSunday.ShouldEqual(new DateTime(2017, 2, 5));
    }

    public class Falls_das_Datum_in_der_SQL_Range_liegen_muss
    {
        private static readonly DateTime SqlMinDate = new DateTime(1753, 1, 1, 12, 01, 00);
        private static readonly DateTime SqlMaxDate = new DateTime(9999, 12, 31, 11, 59, 59);
        private static readonly DateTime ToLow = new DateTime(1752, 1, 1, 1, 1, 1);
        private static readonly DateTime InRange = new DateTime(2017,1,1,10,10,10);
        private static bool _isInRange;
        private static bool _belowRange;
        private static bool _notInRange;
        private static bool _higherAsMin;

        Establish context = () => { };

        Because of = () =>
        {
            _isInRange = InRange.IsInSqlDateTimeRange();
            _belowRange = ToLow.IsBelowSqlMinDate();
            _higherAsMin = InRange.IsBelowSqlMinDate();
            _notInRange = ToLow.IsInSqlDateTimeRange();
        };

        It soll_der_Wert_im_Bereich_liegen_werden = () => _isInRange.ShouldBeTrue();
        It soll_der_Wert_zu_niedrig_sein = () => _belowRange.ShouldBeTrue();
        It soll_der_Wert_Außerhalt_der_Range_sein_Low = () => _notInRange.ShouldBeFalse();
        It soll_der_Wert_größer_als_das_Mindestdatum_sein = () => _higherAsMin.ShouldBeFalse();
    }
}

#pragma warning restore 0169