static void Main(string[] args) { // Test if input arguments were supplied: if ((args.Length == 0) || (args[0] != "xml") || (args[0] != "json")) { System.Console.WriteLine("Please enter a string argument: 'json' or 'xml'."); Console.ReadLine(); return; } IDateExclusionsProvider provider = null; if (args[0] == "xml") { provider = new XmlFileDateExclusionsProvider(); } if (args[0] == "json") { provider = new FromJSonFileDateExclusionsProvider(); } // var jsonprovider = new FromXML2JSonFileDateExclusionsProvider(); // jsonprovider.GetExclusionDates(); Console.Write("Enter the date in the format YY/MM/DD or DD/MM/YYY (or as it will be convenient for you): "); String stDate = Console.ReadLine(); DateTime Dt = Convert.ToDateTime(stDate, CultureInfo.InstalledUICulture); MyLogicClass MyObj = new MyLogicClass(provider); Boolean BoolResult = MyObj.DayCalc(Dt); Console.WriteLine(BoolResult); Console.ReadLine(); }
public void Mytest() { //arrange DateTime dtest = DateTime.Parse("01.06.2018", CultureInfo.InvariantCulture); Boolean ItsWorkday = true; //act var _test_provider = new XmlFileDateExclusionsProvider(); MyLogicClass myTestObj = new MyLogicClass(_test_provider); bool MyrealDay = myTestObj.DayCalc(dtest); //assert Assert.AreEqual(ItsWorkday, MyrealDay); }
public void MyNunitTestMetod1() { //arrange DateTime dtest = DateTime.Parse("01.06.2018", CultureInfo.InvariantCulture); Boolean ItsWorkday = true; //act var _test_provider = new TestExclusionsProvider(new[] { new DateexClass(dtest, true) }); // MyLogicClass myTestObj = new MyLogicClass(_test_provider); bool MyrealDay = myTestObj.DayCalc(dtest); //assert Assert.AreEqual(ItsWorkday, MyrealDay); }
public void MyNUnitTestMetod2() { var dateprovider = Substitute.For <IDateExclusionsProvider>(); //здесь должен быть интерфейс?? List <DateexClass> testdates = new List <DateexClass>(); DateTime dtest = DateTime.Parse("01.06.2018", CultureInfo.InvariantCulture); DateexClass oneday = new DateexClass(dtest, true); testdates.Add(oneday); dateprovider.GetExclusionDates().Returns(testdates); MyLogicClass myTestObj = new MyLogicClass(dateprovider); bool MyrealDay = myTestObj.DayCalc(dtest); //assert Boolean ItsWorkday = true; Assert.AreEqual(ItsWorkday, MyrealDay); //Assert.That(datecontrol.DayCalc(01 / 08 / 2018, false), Is.EqualTo(false); }