Skip to content
Snippets Groups Projects
Commit 7f2762f3 authored by Vesa Lappalainen's avatar Vesa Lappalainen :bicyclist:
Browse files
parents d8e00c6f e0273f8c
No related branches found
No related tags found
No related merge requests found
#EQUALSMARKER2="==>"
\ No newline at end of file
// ReSharper disable all
using System;
using System.Collections.Generic;
using NUnit.Framework;
using static KnapsackProblem;
using System.Linq;
[TestFixture]
[DefaultFloatingPointTolerance(0.000001)]
public class TestKnapsackProblem
{
[Test]
public void Teststatic47()
{
Item[] items = {
new Item("micro", 8, 50),
new Item("drone", 2, 150),
new Item("monitor", 6, 210),
new Item("kettle", 1, 30)
};
(long bestValue, List<Item> used) = KnapsackBruteForce(items, 10);
Assert.AreEqual( 390, bestValue , "in method static, line 58");
Assert.AreEqual(( "drone, monitor, kettle").ToString(), String.Join(", ", used.Select(item => item.name) ), "in method static, line 59");
(bestValue, used) = KnapsackBruteForce(items, 8);
Assert.AreEqual( 360, bestValue , "in method static, line 61");
Assert.AreEqual(( "drone, monitor").ToString(), String.Join(", ", used.Select(item => item.name) ), "in method static, line 62");
(bestValue, used) = KnapsackBruteForce(items, 3);
Assert.AreEqual( 180, bestValue , "in method static, line 64");
Assert.AreEqual(( "drone, kettle").ToString(), String.Join(", ", used.Select(item => item.name) ), "in method static, line 65");
}
}
<?xml version="1.0" encoding="UTF-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NUnit" Version="3.13.1"/>
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\KnapsackProblem\KnapsackProblem.csproj"/>
</ItemGroup>
</Project>

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KnapsackProblem", "KnapsackProblem\KnapsackProblem.csproj", "{41029A20-BE21-4E40-AF2F-E321BEB16B68}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KnapsackProblemTest", "KnapsackProblemTest\KnapsackProblemTest.csproj", "{522FBF6A-58AD-4B3D-8E86-D5BAA27A0EE8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{41029A20-BE21-4E40-AF2F-E321BEB16B68}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{41029A20-BE21-4E40-AF2F-E321BEB16B68}.Debug|Any CPU.Build.0 = Debug|Any CPU
{41029A20-BE21-4E40-AF2F-E321BEB16B68}.Release|Any CPU.ActiveCfg = Release|Any CPU
{41029A20-BE21-4E40-AF2F-E321BEB16B68}.Release|Any CPU.Build.0 = Release|Any CPU
{522FBF6A-58AD-4B3D-8E86-D5BAA27A0EE8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{522FBF6A-58AD-4B3D-8E86-D5BAA27A0EE8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{522FBF6A-58AD-4B3D-8E86-D5BAA27A0EE8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{522FBF6A-58AD-4B3D-8E86-D5BAA27A0EE8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KnapsackProblem", "KnapsackProblem\KnapsackProblem.csproj", "{41029A20-BE21-4E40-AF2F-E321BEB16B68}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{41029A20-BE21-4E40-AF2F-E321BEB16B68}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{41029A20-BE21-4E40-AF2F-E321BEB16B68}.Debug|Any CPU.Build.0 = Debug|Any CPU
{41029A20-BE21-4E40-AF2F-E321BEB16B68}.Release|Any CPU.ActiveCfg = Release|Any CPU
{41029A20-BE21-4E40-AF2F-E321BEB16B68}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment