Esempio n. 1
0
 public void Y2KCheckerTest()
 {
     using (ShimsContext.Create())
     {
         ShimDateTime.NowGet = () => new DateTime(2000, 1, 1);
         Y2KChecker.Check();
     }
 }
Esempio n. 2
0
        public void Y2kCheckerTest()
        {
            using (ShimsContext.Create())
            {
                System.Fakes.ShimDateTime.NowGet = () => new DateTime(2000, 1, 1);


                Assert.ThrowsException <ApplicationException>(() => { Y2KChecker.Check(); });
            }
        }
Esempio n. 3
0
 public void TestMethod1()
 {
     using (ShimsContext.Create())
     {
         // hook delegate to the shim method to redirect DateTime.Now
         // to return January 1st of 2000
         ShimDateTime.NowGet = () => new DateTime(2000, 1, 1);
         Y2KChecker.Check();
     }
 }
Esempio n. 4
0
        public void ThrowIfY2KTest()
        {
            using (ShimsContext.Create())
            {
                var sut = new Y2KChecker();

                ShimDateTime.NowGet = () => new DateTime(2000, 1, 1);

                sut.ThrowIfY2K();
            }
        }
Esempio n. 5
0
        public void TestMethod2()
        {
            using (ShimsContext.Create())
            {
                // hook delegate to the shim method to redirect DateTime.Now
                // to return January 1st of 2000

                ShimFile.ReadAllTextString = (str) => { return("file content"); };

                ShimDateTime.NowGet = () => new DateTime(2001, 1, 1);
                Y2KChecker.Check();
            }
        }
Esempio n. 6
0
 public void HexFile_Constructor()
 {
     //https://www.youtube.com/watch?v=KKiG5NJkqXs
     //https://docs.microsoft.com/en-us/visualstudio/test/using-shims-to-isolate-your-application-from-other-assemblies-for-unit-testing?view=vs-2019
     using (ShimsContext.Create())
     {
         //Arrange
         System.IO.Fakes.ShimFile.ReadAllLinesString = s => new string[] { "1", "1", "1" };
         //System.Fakes.ShimDateTime.NowGet = () =>   { return new DateTime(fixedYear, 1, 1); };
         System.Fakes.ShimDateTime.NowGet = () => new DateTime(2000, 1, 1);
         //Act
         var target = new HexFile("fake.path");
         Y2KChecker.Check();
         //Assert
         Assert.AreEqual(3, target.Record.Length);
     }
 }