Ejemplo n.º 1
0
        public void WriteJson_WrongInput_ExceptionThrown()
        {
            //Arrange
            var unixTimeConverter = new UnixTime.UnixTimeConverter();

            //Act
            var ex = Assert.Throws <ArgumentException>(() => unixTimeConverter.WriteJson(null, string.Empty, null));

            //Assert
            Assert.Equal("Expect DateTime as input parameter", ex.Message);
        }
Ejemplo n.º 2
0
        public void WriteJson_FullDate_SuccessResult()
        {
            //Arrange
            var unixTimeConverter = new UnixTime.UnixTimeConverter();
            var jsonWriterMock    = new Mock <JsonWriter>();

            //Act
            unixTimeConverter.WriteJson(jsonWriterMock.Object, new DateTime(2017, 08, 04, 16, 2, 2, DateTimeKind.Utc), null);

            //Assert
            jsonWriterMock.Verify(x => x.WriteValue(1501862522L), Times.Once);
        }
Ejemplo n.º 3
0
        public void WriteJson_MoreThan1970_SuccessResult()
        {
            //Arrange
            var unixTimeConverter = new UnixTime.UnixTimeConverter();
            var jsonWriterMock    = new Mock <JsonWriter>();

            //Act
            unixTimeConverter.WriteJson(jsonWriterMock.Object, new DateTime(1971, 1, 1, 0, 0, 0, DateTimeKind.Utc), null);

            //Assert
            jsonWriterMock.Verify(x => x.WriteValue(31536000L), Times.Once);
        }