// Copyright 2020 De Staat der Nederlanden, Ministerie van Volksgezondheid, Welzijn en Sport.
// Licensed under the EUROPEAN UNION PUBLIC LICENCE v. 1.2
// SPDX-License-Identifier: EUPL-1.2

using System;
using Iks.Protobuf;
using NL.Rijksoverheid.ExposureNotification.BackEnd.Iks.Commands.Outbound;
using Xunit;

namespace NL.Rijksoverheid.ExposureNotification.BackEnd.Iks.Commands.Tests.IksOutbound
{
    public class EfgsDiagnosisKeyBatchSerializerTests
    {
        [Fact]
        public void Test_with_EFGS_test_case()
        {
            // Assemble
            var serializer = new EfgsDiagnosisKeyBatchSerializer();
            var diagnosisKeyBatch = DiagnosisKeyBatch.Parser.ParseFrom(Convert.FromBase64String(MessageB64));
            var expectedResult = Convert.FromBase64String(ExpectedResultB64);

            // Act
            var result = serializer.Serialize(diagnosisKeyBatch);

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

        // Note: this test case was generated by the EFGS unit tests and is known to be good.
        private const string MessageB64 = "CiMKAzk3OBACGAEgAyoCQ0EqAkNCKgJDQyoCQ0QyAkRFOAFAVAokCgREMTg5EAIYASADKgJDQSoCQ0IqAkNDKgJDRDICREU4AUBUCiMKA0FCQxACGAEgAyoCQ0EqAkNCKgJDQyoCQ0QyAkRFOAFAVAojCgMxMjMQAhgBIAMqAkNBKgJDQioCQ0MqAkNEMgJERTgBQFQ=";
        private const string ExpectedResultB64 = "T1RjNC5BQUFBQWc9PS5BQUFBQVE9PS5BQUFBQXc9PS5RMEVzUTBJc1EwTXNRMFE9LlJFVT0uQUFBQUFRPT0uQUFBQUtnPT0uTVRJei5BQUFBQWc9PS5BQUFBQVE9PS5BQUFBQXc9PS5RMEVzUTBJc1EwTXNRMFE9LlJFVT0uQUFBQUFRPT0uQUFBQUtnPT0uUVVKRC5BQUFBQWc9PS5BQUFBQVE9PS5BQUFBQXc9PS5RMEVzUTBJc1EwTXNRMFE9LlJFVT0uQUFBQUFRPT0uQUFBQUtnPT0uUkRFNE9RPT0uQUFBQUFnPT0uQUFBQUFRPT0uQUFBQUF3PT0uUTBFc1EwSXNRME1zUTBRPS5SRVU9LkFBQUFBUT09LkFBQUFLZz09Lg==";
    }
}
