Пример #1
0
        public void CurrentUtcDateTime()
        {
            using (ShimsContext.Create())
            {
                // Arrange
                var componentUnderTest = new DefaultNetworkContext();
                var expected           = new DateTime(2000, 1, 2);
                System.Fakes.ShimDateTime.UtcNowGet = () => expected;

                // Act
                var actual = componentUnderTest.CurrentUtcDateTime;

                // Assert
                actual.ShouldHaveSameValueAs(expected);
            }
        }
Пример #2
0
        public void NewGuid()
        {
            using (ShimsContext.Create())
            {
                // Arrange
                var componentUnderTest = new DefaultNetworkContext();
                var expected           = Guid.Parse("00000000-0000-0000-0000-000000001234");
                System.Fakes.ShimGuid.NewGuid = () => expected;

                // Act
                var actual = componentUnderTest.NewGuid;

                // Assert
                actual.ShouldHaveSameValueAs(expected);
            }
        }
Пример #3
0
        public void ToBytes()
        {
            // Arrange
            var componentUnderTest = new DefaultNetworkContext();
            var original           = new byte[] { 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 };
            var expected           = new byte[] { 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 };

            using (var stream = new MemoryStream(original))
            {
                // Act
                var actual = componentUnderTest.ToBytes(stream);

                // Assert
                actual.ShouldHaveSameValueAs(expected);
            }
        }