Exemplo n.º 1
0
        public void PayloadHelper_BuildArrayPayload_NullParam()
        {
            Action act = () => PayloadHelper.BuildArrayPayload(null);

            act.Should().Throw <ArgumentNullException>()
            .And.ParamName.Should().Be("entities");
        }
Exemplo n.º 2
0
        public void PayloadHelper_BuildArrayPayload_ValidateArray()
        {
            // arrange
            string floorJson = TestAssetsHelper.GetFloorModelPayload(
                TestAssetSettings.Instance.FloorModelId,
                TestAssetSettings.Instance.RoomModelId,
                TestAssetSettings.Instance.HvacModelId);
            string roomJson = TestAssetsHelper.GetRoomModelPayload(TestAssetSettings.Instance.RoomModelId, TestAssetSettings.Instance.FloorModelId);
            var    models   = new List <string> {
                floorJson, roomJson
            };

            // act
            string creationPayload = PayloadHelper.BuildArrayPayload(models);

            // assert
            creationPayload.Should().NotBeNullOrEmpty();
            JsonDocument parsedJson = JsonDocument.Parse(creationPayload);

            parsedJson.RootElement.ValueKind.Should().Be(JsonValueKind.Array);
            parsedJson.RootElement.GetArrayLength().Should().Be(models.Count);
            parsedJson.RootElement[0].ToString().Should().Be(floorJson);
            parsedJson.RootElement[1].ToString().Should().Be(roomJson);
        }