blob: 35211a1bef66fdadc899eb12569ea582b0dabb85 (
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
51
52
53
54
55
56
57
58
|
using System;
using System.Collections.Generic;
using Xamarin.Forms;
using NUnit.Framework;
namespace Xamarin.Forms.Xaml.UnitTests
{
public class Bz27299ViewModel
{
public string Text {
get { return "Foo"; }
}
}
public class Bz27299ViewModelLocator
{
public static int Count { get; set; }
public object Bz27299 {
get {
Count++;
return new Bz27299ViewModel ();
}
}
}
public partial class Bz27299 : ContentPage
{
public Bz27299 ()
{
InitializeComponent ();
}
public Bz27299 (bool useCompiledXaml)
{
//this stub will be replaced at compile time
}
[TestFixture]
class Tests
{
[SetUp]
public void SetUp ()
{
Bz27299ViewModelLocator.Count = 0;
}
[TestCase(true)]
[TestCase(false)]
public void ViewModelLocatorOnlyCalledOnce (bool useCompiledXaml)
{
Assert.AreEqual (0, Bz27299ViewModelLocator.Count);
var layout = new Bz27299 (useCompiledXaml);
Assert.AreEqual (1, Bz27299ViewModelLocator.Count);
Assert.AreEqual ("Foo", layout.label.Text);
}
}
}
}
|