﻿using Knapsack.Solutions.Common;
using Xunit;

namespace Knapsack.Tests
{
    internal class Common
    {
        private const double TimeoutInMinutes = 10;
        internal const int Timeout = (int)(TimeoutInMinutes * 60 * 1000);

        public static void CheckOutput(Input input, Output output)
        {
            int actualValue = 0;
            int actualCapacityCost = 0;

            for (int i = 0; i < input.N; i++)
            {
                if (output.Selections[i] == 1)
                {
                    actualValue += input.Items[i].Value;
                    actualCapacityCost += input.Items[i].Weight;
                }
            }
            Assert.Equal(output.Value, actualValue);
            Assert.True(actualCapacityCost <= input.Capacity);
        }
    }
}
