Esempio n. 1
0
        public void Enum_In(Entity.NotificationEncodings value, Entity.NotificationEncodings[] inValues, bool expectedResult)
        {
            // Arrange
            // Act
            var result = value.In(inValues);

            // Assert
            result.Should().Be(expectedResult);
        }
Esempio n. 2
0
        public void Write(Entity.NotificationEncodings value, string expectedResult)
        {
            // Arrange
            var options = new JsonSerializerOptions();

            using var stream = new MemoryStream();
            using var writer = new Utf8JsonWriter(stream);
            var converter = new EnumValueJsonConverter <Entity.NotificationEncodings>();

            writer.WriteStartObject();
            writer.WritePropertyName("test");

            // Act
            converter.Write(writer, value, options);

            // Assert
            writer.WriteEndObject();
            writer.Flush();
            var result = Encoding.UTF8.GetString(stream.ToArray());

            Assert.Equal(expectedResult, result);
        }
Esempio n. 3
0
        public void Read(string value, Entity.NotificationEncodings expectedResult)
        {
            // Arrange
            var options = new JsonSerializerOptions();

            var jsonUtf8Bytes = System.Text.Json.JsonSerializer.SerializeToUtf8Bytes(value, options);
            var reader        = new Utf8JsonReader(jsonUtf8Bytes);
            var converter     = new EnumValueJsonConverter <Entity.NotificationEncodings>();

            while (reader.Read())
            {
                if (reader.TokenType == JsonTokenType.String)
                {
                    break;
                }
            }

            // Act
            var result = converter.Read(ref reader, typeof(bool), options);

            // Assert
            Assert.Equal(expectedResult, result);
        }