コード例 #1
0
ファイル: Y2KBugTest.cs プロジェクト: staherianYMCA/test
 public void Y2KCheckerTest()
 {
     using (ShimsContext.Create())
     {
         ShimDateTime.NowGet = () => new DateTime(2000, 1, 1);
         Y2KChecker.Check();
     }
 }
コード例 #2
0
ファイル: UnitTest1.cs プロジェクト: FredWings/UnitTest
        public void Y2kCheckerTest()
        {
            using (ShimsContext.Create())
            {
                System.Fakes.ShimDateTime.NowGet = () => new DateTime(2000, 1, 1);


                Assert.ThrowsException <ApplicationException>(() => { Y2KChecker.Check(); });
            }
        }
コード例 #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();
     }
 }
コード例 #4
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();
            }
        }
コード例 #5
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);
     }
 }