Welcome to mirror list, hosted at ThFree Co, Russian Federation.

FloatingPropertyViewModelTests.cs « Xamarin.PropertyEditing.Tests - github.com/xamarin/Xamarin.PropertyEditing.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7a2240590df3105b9965712d9fe93623891b4e95 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System;
using System.Collections.Generic;
using NUnit.Framework;
using Xamarin.PropertyEditing.ViewModels;

namespace Xamarin.PropertyEditing.Tests
{
	[TestFixture]
	internal class FloatingPropertyViewModelTests
		: NumericViewModelTests<double, double>
	{
		protected override double GetRandomTestValue (Random rand)
		{
			return rand.NextDouble ();
		}

		protected override NumericPropertyViewModel<double> GetViewModel (TargetPlatform platform, IPropertyInfo property, IEnumerable<IObjectEditor> editors)
		{
			return new NumericPropertyViewModel<double> (platform, property, editors);
		}

		protected override Tuple<double, double> MaxMin => new Tuple<double, double> (Double.MaxValue, Double.MinValue);

		protected override double GetConstrainedRandomValue (Random rand, out double max, out double min)
		{
			int value = rand.Next (2, Int32.MaxValue - 2);
			max = rand.Next (value + 1, Int32.MaxValue);
			min = rand.Next (0, value - 1);
			return value;
		}

		protected override double GetConstrainedRandomValueAboveBounds (Random rand, out double max, out double min)
		{
			int value = rand.Next (2, Int32.MaxValue - 2);
			min = rand.Next (0, value - 1);
			max = rand.Next ((int)min + 1, value - 1);

			return value;
		}

		protected override double GetConstrainedRandomValueBelowBounds (Random rand, out double max, out double min)
		{
			int value = rand.Next (2, Int32.MaxValue - 2);
			max = rand.Next (value + 1, Int32.MaxValue);
			min = rand.Next (value + 1, (int)max - 1);

			return value;
		}
	}
}