Skip to content

Commit e689f71

Browse files
author
Tomasz Szymański
committed
Manual Merge Tests -> Master
1 parent f391e8b commit e689f71

16 files changed

+645
-186
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
using UnityEngine;
2+
using UnityEditor;
3+
using NUnit.Framework;
4+
using Assets.Scripts.Database.Models;
5+
using Assets.Scripts.Database.Controllers;
6+
using System;
7+
using System.Collections.Generic;
8+
using Assets.Scripts.Database;
9+
10+
public class OptionControllerTest
11+
{
12+
13+
[SetUp]
14+
public void Init()
15+
{
16+
17+
}
18+
19+
[Test]
20+
[Category("CompareTo")]
21+
public void CompareToSameValue([Values(OptionName.Controls, OptionName.Sound, OptionName.UnlockedLevel)] string option, [Values(OptionName.Controls, OptionName.Sound, OptionName.UnlockedLevel)] string comparer)
22+
{
23+
Option o = new Option() { Name = option, Value = OnOffOption.On };
24+
Option c = new Option() { Name = comparer, Value = OnOffOption.On };
25+
26+
int result = o.CompareTo(c);
27+
int expected = option.CompareTo(comparer);
28+
29+
30+
Assert.AreEqual(expected, result);
31+
}
32+
33+
[Test]
34+
[Category("CompareTo")]
35+
public void CompareToDiffrentValue([Values(OptionName.Controls, OptionName.Sound, OptionName.UnlockedLevel)] string option, [Values(OptionName.Controls, OptionName.Sound, OptionName.UnlockedLevel)] string comparer)
36+
{
37+
Option o = new Option() { Name = option, Value = OnOffOption.On };
38+
Option c = new Option() { Name = comparer, Value = OnOffOption.Off };
39+
40+
int result = o.CompareTo(c);
41+
int expected = option.CompareTo(comparer);
42+
43+
44+
Assert.AreEqual(expected, result);
45+
}
46+
47+
[Test]
48+
[Category("Equals")]
49+
public void EqualsSameValue([Values(OptionName.Controls, OptionName.Sound, OptionName.UnlockedLevel)] string option, [Values(OptionName.Controls, OptionName.Sound, OptionName.UnlockedLevel)] string comparer)
50+
{
51+
Option o = new Option() { Name = option, Value = OnOffOption.On };
52+
Option c = new Option() { Name = comparer, Value = OnOffOption.On };
53+
54+
bool result = o.Equals(c);
55+
bool expected = option.Equals(comparer);
56+
57+
58+
Assert.AreEqual(expected, result);
59+
}
60+
61+
[Test]
62+
[Category("Equals")]
63+
public void EqualsDiffrentValue([Values(OptionName.Controls, OptionName.Sound, OptionName.UnlockedLevel)] string option, [Values(OptionName.Controls, OptionName.Sound, OptionName.UnlockedLevel)] string comparer)
64+
{
65+
Option o = new Option() { Name = option, Value = OnOffOption.On };
66+
Option c = new Option() { Name = comparer, Value = OnOffOption.Off };
67+
68+
bool result = o.Equals(c);
69+
bool expected = option.Equals(comparer);
70+
71+
72+
Assert.AreEqual(expected, result);
73+
}
74+
75+
[Test]
76+
[Category("Equals")]
77+
public void GetDefault([Values(OptionName.Controls, OptionName.Sound, OptionName.UnlockedLevel)] string option)
78+
{
79+
Option o = Option.GetDefault(option);
80+
81+
Option expected;
82+
83+
switch (option)
84+
{
85+
case OptionName.Controls:
86+
expected = new Option() { Name = OptionName.Controls, Value = ControlOption.Arrows };
87+
break;
88+
case OptionName.Music:
89+
expected = new Option() { Name = OptionName.Music, Value = OnOffOption.On };
90+
break;
91+
case OptionName.Sound:
92+
expected = new Option() { Name = OptionName.Sound, Value = OnOffOption.On };
93+
break;
94+
case OptionName.UnlockedLevel:
95+
expected = new Option() { Name = OptionName.UnlockedLevel, Value = UnlockedLevelOption.Level_1 };
96+
break;
97+
default:
98+
expected = null;
99+
break;
100+
}
101+
102+
103+
Assert.AreEqual(expected.Name, o.Name);
104+
Assert.AreEqual(expected.Value, o.Value);
105+
}
106+
}

BreakoutUnity/Breakout/Assets/Editor/OptionControllerTest.cs.meta

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)