// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.billing.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.billing.fluent.models.InstructionInner;
import java.time.OffsetDateTime;
import org.junit.jupiter.api.Assertions;

public final class InstructionInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        InstructionInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"amount\":10.419273,\"startDate\":\"2021-09-25T01:29:01Z\",\"endDate\":\"2021-09-15T09:48:55Z\",\"creationDate\":\"2021-10-30T19:28:33Z\"},\"id\":\"ypewrmjmwvvjekt\",\"name\":\"xsenhwlr\",\"type\":\"ffrzpwvlqdqgbiqy\"}")
                .toObject(InstructionInner.class);
        Assertions.assertEquals(10.419273f, model.amount());
        Assertions.assertEquals(OffsetDateTime.parse("2021-09-25T01:29:01Z"), model.startDate());
        Assertions.assertEquals(OffsetDateTime.parse("2021-09-15T09:48:55Z"), model.endDate());
        Assertions.assertEquals(OffsetDateTime.parse("2021-10-30T19:28:33Z"), model.creationDate());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        InstructionInner model =
            new InstructionInner()
                .withAmount(10.419273f)
                .withStartDate(OffsetDateTime.parse("2021-09-25T01:29:01Z"))
                .withEndDate(OffsetDateTime.parse("2021-09-15T09:48:55Z"))
                .withCreationDate(OffsetDateTime.parse("2021-10-30T19:28:33Z"));
        model = BinaryData.fromObject(model).toObject(InstructionInner.class);
        Assertions.assertEquals(10.419273f, model.amount());
        Assertions.assertEquals(OffsetDateTime.parse("2021-09-25T01:29:01Z"), model.startDate());
        Assertions.assertEquals(OffsetDateTime.parse("2021-09-15T09:48:55Z"), model.endDate());
        Assertions.assertEquals(OffsetDateTime.parse("2021-10-30T19:28:33Z"), model.creationDate());
    }
}
