RunningApp.Tap (q => q.Marked ("btnDismissModal"));
RunningApp.Tap (q => q.Marked ("btnMaster"));
}
+ else
+ {
+ // Wait for the test to finish loading before exiting otherwise
+ // the next UI test might start running while this is still loading
+ RunningApp.WaitForElement(q => q.Marked("btnModal"));
+ }
}
[TearDown]
#if UITEST && __IOS__
[Test]
[Category(UITestCategories.ManualReview)]
- [Ignore]
+ [Ignore("Fails sometimes")]
public void Bugzilla35736Test()
{
RunningApp.WaitForElement(q => q.Marked("Bugzilla35736Editor"));
public void SwipeRight()
{
-#pragma warning disable 618
- _app.SwipeRight();
-#pragma warning restore 618
+ SwipeLeftToRight();
}
public void SwipeLeftToRight(double swipePercentage = 0.67, int swipeSpeed = 500, bool withInertia = true)
public void SwipeLeft()
{
-#pragma warning disable 618
- _app.SwipeLeft();
-#pragma warning restore 618
+ SwipeRightToLeft();
}
public void SwipeRightToLeft(double swipePercentage = 0.67, int swipeSpeed = 500, bool withInertia = true)
[SetUpFixture]
public class IssuesSetup
{
- [SetUp]
+ [OneTimeSetUp]
public void RunBeforeAnyTests()
{
AppSetup.RunningApp = AppSetup.Setup(null);
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
- <PackageReference Include="NUnit" Version="2.6.4" />
- <PackageReference Include="NUnitTestAdapter">
- <Version>2.2.0</Version>
- </PackageReference>
+ <PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="Xam.Plugin.DeviceInfo" Version="3.0.2" />
- <PackageReference Include="Xamarin.UITest" Version="2.2.7" />
+ <PackageReference Include="Xamarin.UITest" Version="3.0.3" />
+ <PackageReference Include="NUnit3TestAdapter">
+ <Version>3.15.1</Version>
+ </PackageReference>
</ItemGroup>
<ItemGroup>
<Compile Include="BaseViewContainerRemoteAndroid.cs" />
public static AppRect ScreenBounds { get; set; }
- [TestFixtureTearDown]
+ [OneTimeTearDown]
protected virtual void FixtureTeardown()
{
}
[SetUp]
protected virtual void TestSetup()
{
- EnsureMemory();
+ //EnsureMemory();
}
[TearDown]
protected abstract void NavigateToGallery();
-#pragma warning disable 618
- [TestFixtureSetUp]
-#pragma warning restore 618
+ [OneTimeSetUp]
protected virtual void FixtureSetup()
{
ResetApp();
}
}
}
-
#if UITEST
namespace Xamarin.Forms.Core.UITests
[SetUpFixture]
public class CoreUITestsSetup
{
- [SetUp]
+ [OneTimeSetUp]
public void RunBeforeAnyTests()
{
LaunchApp();
}
}
-#endif
\ No newline at end of file
+#endif
{
[Test]
//https://bugzilla.xamarin.com/show_bug.cgi?id=51424
- public async void AnimationRepeats()
+ public async Task AnimationRepeats()
{
var box = new BoxView();
Assume.That(box.Rotation, Is.EqualTo(0d));
Assert.That (() => bindable.SetBinding (MockBindable.TextProperty, new Binding ("Text2")), Throws.Nothing);
Assert.That (bindable.Text, Is.EqualTo (MockBindable.TextProperty.DefaultValue));
Assert.That (log.Messages.Count, Is.EqualTo (1), "An error was not logged");
- Assert.That (log.Messages[0], Is.StringContaining (String.Format (BindingExpression.PropertyNotFoundErrorMessage,
+ Assert.That (log.Messages[0], Does.Contain(String.Format (BindingExpression.PropertyNotFoundErrorMessage,
"Text2",
"Xamarin.Forms.Core.UnitTests.BindingUnitTests+DifferentViewModel",
"Xamarin.Forms.Core.UnitTests.MockBindable",
Assert.That (bindable.Text, Is.EqualTo ("Foo"));
Assert.That (log.Messages.Count, Is.Not.GreaterThan (1), "Too many errors were logged");
- Assert.That (log.Messages[0], Is.StringContaining (String.Format (BindingExpression.PropertyNotFoundErrorMessage,
+ Assert.That (log.Messages[0], Does.Contain(String.Format (BindingExpression.PropertyNotFoundErrorMessage,
"Text",
"Xamarin.Forms.Core.UnitTests.BindingUnitTests+EmptyViewModel",
"Xamarin.Forms.Core.UnitTests.MockBindable",
Assert.That (() => bindable.SetBinding (MockBindable.TextProperty, new Binding ("Text")), Throws.Nothing);
Assert.That (log.Messages.Count, Is.EqualTo (1), "An error was not logged");
- Assert.That (log.Messages[0], Is.StringContaining (String.Format (BindingExpression.PropertyNotFoundErrorMessage,
+ Assert.That (log.Messages[0], Does.Contain(String.Format (BindingExpression.PropertyNotFoundErrorMessage,
"Text",
"Xamarin.Forms.Core.UnitTests.BindingUnitTests+DifferentViewModel",
"Xamarin.Forms.Core.UnitTests.MockBindable",
Assert.That (() => bindable.SetBinding (MockBindable.TextProperty, new Binding ("PrivateSetter")), Throws.Nothing);
Assert.That (log.Messages.Count, Is.EqualTo (1), "An error was not logged");
- Assert.That (log.Messages[0], Is.StringContaining (String.Format (BindingExpression.PropertyNotFoundErrorMessage,
+ Assert.That (log.Messages[0], Does.Contain(String.Format (BindingExpression.PropertyNotFoundErrorMessage,
"PrivateSetter",
"Xamarin.Forms.Core.UnitTests.BindingUnitTests+DifferentViewModel",
"Xamarin.Forms.Core.UnitTests.MockBindable",
Assert.That (() => bindable.SetValueCore (MockBindable.TextProperty, "foo"), Throws.Nothing);
Assert.That (log.Messages.Count, Is.EqualTo (2), "An error was not logged");
- Assert.That (log.Messages[1], Is.StringContaining (String.Format (BindingExpression.PropertyNotFoundErrorMessage,
+ Assert.That (log.Messages[1], Does.Contain(String.Format (BindingExpression.PropertyNotFoundErrorMessage,
"PrivateSetter",
"Xamarin.Forms.Core.UnitTests.BindingUnitTests+DifferentViewModel",
"Xamarin.Forms.Core.UnitTests.MockBindable",
Assert.That (() => bindable.SetBinding (MockBindable.TextProperty, new Binding ("MissingProperty")), Throws.Nothing);
Assert.That (log.Messages.Count, Is.EqualTo (1), "An error was not logged");
- Assert.That (log.Messages[0], Is.StringContaining (String.Format (BindingExpression.PropertyNotFoundErrorMessage,
+ Assert.That (log.Messages[0], Does.Contain(String.Format (BindingExpression.PropertyNotFoundErrorMessage,
"MissingProperty",
"Xamarin.Forms.Core.UnitTests.MockViewModel",
"Xamarin.Forms.Core.UnitTests.MockBindable",
Assert.That (() => bindable.SetBinding (MockBindable.TextProperty, new Binding ("Model.MissingProperty")), Throws.Nothing);
Assert.That (log.Messages.Count, Is.EqualTo (1), "An error was not logged");
- Assert.That (log.Messages[0], Is.StringContaining (String.Format (BindingExpression.PropertyNotFoundErrorMessage,
+ Assert.That (log.Messages[0], Does.Contain(String.Format (BindingExpression.PropertyNotFoundErrorMessage,
"MissingProperty",
"Xamarin.Forms.Core.UnitTests.BindingBaseUnitTests+ComplexMockViewModel",
"Xamarin.Forms.Core.UnitTests.MockBindable",
using NUnit.Framework;
using System;
+using System.Threading.Tasks;
namespace Xamarin.Forms.Core.UnitTests
{
}
[Test]
- public async void ForceUpdateSizeCallsAreRateLimited()
+ public async Task ForceUpdateSizeCallsAreRateLimited()
{
var lv = new ListView { HasUnevenRows = true };
var cell = new ViewCell { Parent = lv };
}
[Test]
- public async void ForceUpdateSizeWillNotBeCalledIfParentIsNotAListViewWithUnevenRows ()
+ public async Task ForceUpdateSizeWillNotBeCalledIfParentIsNotAListViewWithUnevenRows ()
{
var lv = new ListView { HasUnevenRows = false };
var cell = new ViewCell { Parent = lv };
public class GeocoderUnitTests : BaseTestFixture
{
[Test]
- public async void AddressesForPosition ()
+ public async Task AddressesForPosition ()
{
Geocoder.GetAddressesForPositionFuncAsync = GetAddressesForPositionFuncAsync;
var geocoder = new Geocoder ();
}
[Test]
- public async void PositionsForAddress () {
+ public async Task PositionsForAddress () {
Geocoder.GetPositionsForAddressAsyncFunc = GetPositionsForAddressAsyncFunc ;
var geocoder = new Geocoder ();
var result = await geocoder.GetPositionsForAddressAsync ("quux");
[TestFixture]
public class MotionTests : BaseTestFixture
{
- [TestFixtureSetUp]
+ [OneTimeSetUp]
public void Init ()
{
Device.PlatformServices = new MockPlatformServices ();
Ticker.Default = new BlockingTicker ();
}
- [TestFixtureTearDown]
+ [OneTimeTearDown]
public void End ()
{
Device.PlatformServices = null;
[TestFixture]
public class TickerSystemEnabledTests
{
- [TestFixtureSetUp]
+ [OneTimeSetUp]
public void Init ()
{
Device.PlatformServices = new MockPlatformServices ();
Ticker.Default = new AsyncTicker();
}
- [TestFixtureTearDown]
+ [OneTimeTearDown]
public void End ()
{
Device.PlatformServices = null;
}
[Test]
- public async void HandlesPopToRoot ()
+ public async Task HandlesPopToRoot ()
{
var root = new ContentPage { Title = "Root" };
var navPage = new NavigationPage (root);
}
[Test]
- public async void NavigatesBackWhenBackButtonPressed ()
+ public async Task NavigatesBackWhenBackButtonPressed ()
{
var root = new ContentPage { Title = "Root" };
var navPage = new NavigationPage (root);
}
[Test]
- public async void DoesNotNavigatesBackWhenBackButtonPressedIfHandled ()
+ public async Task DoesNotNavigatesBackWhenBackButtonPressedIfHandled ()
{
var root = new BackButtonPage { Title = "Root" };
var second = new BackButtonPage () {Handle = true};
}
[Test]
- public async void TestRemovePage()
+ public async Task TestRemovePage()
{
var root = new ContentPage { Title = "Root" };
var newPage = new ContentPage();
var rd = new ResourceDictionary();
rd.Add("foo", "bar");
var ex = Assert.Throws<KeyNotFoundException>(() => { var foo = rd ["test_invalid_key"]; });
- Assert.That(ex.Message, Is.StringContaining("test_invalid_key"));
+ Assert.That(ex.Message, Does.Contain("test_invalid_key"));
}
class MyRD : ResourceDictionary
[Test]
//https://bugzilla.xamarin.com/show_bug.cgi?id=31207
- public async void StyleDontHoldStrongReferences ()
+ public async Task StyleDontHoldStrongReferences ()
{
var style = new Style (typeof(Label));
var label = new Label ();
}
[Test]
- [Ignore]
+ [Ignore("SpeedTestApply")]
public void SpeedTestApply()
{
}
[Test]
- [Ignore]
+ [Ignore("SpeedTestSetBC")]
public void SpeedTestSetBC()
{
var property = BindableProperty.Create("Foo", typeof(string), typeof(MockBindable));
}
[Test]
- [Ignore]
+ [Ignore("LoadImageFromStream")]
public void LoadImageFromStream ()
{
var loader = new UriImageSource {
}
[Test]
- [Ignore]
+ [Ignore("SecondCallLoadFromCache")]
public void SecondCallLoadFromCache ()
{
var loader = new UriImageSource {
}
[Test]
- [Ignore]
+ [Ignore("DoNotKeepFailedRetrieveInCache")]
public void DoNotKeepFailedRetrieveInCache ()
{
var loader = new UriImageSource {
}
[Test]
- [Ignore]
+ [Ignore("ConcurrentCallsOnSameUriAreQueued")]
public void ConcurrentCallsOnSameUriAreQueued ()
{
var loader = new UriImageSource {
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
- <PackageReference Include="NUnit" Version="2.6.4" />
- <PackageReference Include="NUnitTestAdapter" Version="2.2.0" />
+ <PackageReference Include="NUnit" Version="3.12.0" />
+ <PackageReference Include="NUnit3TestAdapter">
+ <Version>3.15.1</Version>
+ </PackageReference>
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Target Name="_CopyNUnitTestAdapterFiles" AfterTargets="Build">
<ItemGroup>
- <_NUnitTestAdapterFiles Include="$(NuGetPackageRoot)NUnitTestAdapter\%(Version)\**" Condition="@(PackageReference -> '%(Identity)') == 'NUnitTestAdapter'" InProject="False" />
+ <_NUnitTestAdapterFiles Include="$(NuGetPackageRoot)NUnit3TestAdapter\%(Version)\build\net35\**" Condition="@(PackageReference -> '%(Identity)') == 'NUnit3TestAdapter'" InProject="False" />
</ItemGroup>
- <Copy SourceFiles="@(_NUnitTestAdapterFiles)" DestinationFolder="$(SolutionDir)packages\NUnitTestAdapter.AnyVersion\%(RecursiveDir)" ContinueOnError="true" Retries="0" />
+ <Copy SourceFiles="@(_NUnitTestAdapterFiles)" DestinationFolder="$(SolutionDir)packages\NUnitTestAdapter.AnyVersion\tools\%(RecursiveDir)" ContinueOnError="true" Retries="0" />
+ <Copy SourceFiles="@(_NUnitTestAdapterFiles)" DestinationFolder="$(SolutionDir)packages\NUnitTestAdapter.AnyVersion\build\%(RecursiveDir)" ContinueOnError="true" Retries="0" />
</Target>
</Project>
\ No newline at end of file
<PackageReference Include="Castle.Core" Version="4.3.1" />
<PackageReference Include="DotNetSeleniumExtras.PageObjects" Version="3.11.0" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
- <PackageReference Include="NUnit" Version="2.6.4" />
- <PackageReference Include="NUnitTestAdapter">
- <Version>2.2.0</Version>
- </PackageReference>
+ <PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="Selenium.Support" Version="3.14.0" />
<PackageReference Include="Selenium.WebDriver" Version="3.14.0" />
<PackageReference Include="Xam.Plugin.DeviceInfo" Version="3.0.2" />
- <PackageReference Include="Xamarin.UITest" Version="2.2.7" />
+ <PackageReference Include="Xamarin.UITest" Version="3.0.3" />
+ <PackageReference Include="NUnit3TestAdapter">
+ <Version>3.15.1</Version>
+ </PackageReference>
</ItemGroup>
<ItemGroup>
<Compile Include="WindowsTestBase.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
- <PackageReference Include="NUnit" Version="2.6.4" />
+ <PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="Xam.Plugin.DeviceInfo" Version="3.0.2" />
- <PackageReference Include="Xamarin.UITest" Version="2.2.7" />
+ <PackageReference Include="Xamarin.UITest" Version="3.0.3" />
</ItemGroup>
<ItemGroup>
<Compile Include="BaseViewContainerRemoteiOS.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
- <PackageReference Include="NUnit" Version="2.6.4" />
+ <PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="ServiceStack.Client" Version="4.5.12" />
<PackageReference Include="ServiceStack.Interfaces" Version="4.5.12" />
<PackageReference Include="ServiceStack.Text" Version="4.5.12" />
<PackageReference Include="Xam.Plugin.DeviceInfo" Version="3.0.2" />
- <PackageReference Include="Xamarin.UITest" Version="2.2.7" />
+ <PackageReference Include="Xamarin.UITest" Version="3.0.3" />
<PackageReference Include="Xamarin.UITest.Desktop" Version="0.0.7" />
</ItemGroup>
<ItemGroup>
</ItemGroup>
<Copy SourceFiles="@(_XamarinUITestFiles)" DestinationFolder="$(SolutionDir)packages\Xamarin.UITest.AnyVersion\%(RecursiveDir)" ContinueOnError="true" Retries="0" />
</Target>
-</Project>
+</Project>
\ No newline at end of file
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
- <PackageReference Include="NUnit" Version="2.6.4" />
- <PackageReference Include="NUnitTestAdapter" Version="2.2.0" />
+ <PackageReference Include="NUnit" Version="3.12.0" />
+ <PackageReference Include="NUnit3TestAdapter">
+ <Version>3.15.1</Version>
+ </PackageReference>
</ItemGroup>
<ItemGroup>
<Compile Include="..\Xamarin.Forms.Core.UnitTests\MockDispatcherProvider.cs">
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="_CopyNUnitTestAdapterFiles" AfterTargets="Build">
<ItemGroup>
- <_NUnitTestAdapterFiles Include="$(NuGetPackageRoot)NUnitTestAdapter\%(Version)\**" Condition="@(PackageReference -> '%(Identity)') == 'NUnitTestAdapter'" InProject="False" />
+ <_NUnitTestAdapterFiles Include="$(NuGetPackageRoot)NUnit3TestAdapter\%(Version)\build\net35\**" Condition="@(PackageReference -> '%(Identity)') == 'NUnit3TestAdapter'" InProject="False" />
</ItemGroup>
- <Copy SourceFiles="@(_NUnitTestAdapterFiles)" DestinationFolder="$(SolutionDir)packages\NUnitTestAdapter.AnyVersion\%(RecursiveDir)" ContinueOnError="true" Retries="0" />
+ <Copy SourceFiles="@(_NUnitTestAdapterFiles)" DestinationFolder="$(SolutionDir)packages\NUnitTestAdapter.AnyVersion\tools\%(RecursiveDir)" ContinueOnError="true" Retries="0" />
+ <Copy SourceFiles="@(_NUnitTestAdapterFiles)" DestinationFolder="$(SolutionDir)packages\NUnitTestAdapter.AnyVersion\build\%(RecursiveDir)" ContinueOnError="true" Retries="0" />
</Target>
</Project>
\ No newline at end of file
Assert.That(page.Content.BackgroundColor, Is.EqualTo(Color.Red));
}
- [Test][Ignore]
+ [Test][Ignore(nameof(ImplicitStyleAppliedToMissingType))]
public void ImplicitStyleAppliedToMissingType()
{
XamlLoader.FallbackTypeResolver = (p, type) => type ?? typeof(Button);
Assert.That(myButton.BackgroundColor, Is.Not.EqualTo(Color.Red));
}
- [Test][Ignore]
+ [Test][Ignore(nameof(StyleTargetingMissingTypeNotAppliedToFallbackType))]
public void StyleTargetingMissingTypeNotAppliedToFallbackType()
{
XamlLoader.FallbackTypeResolver = (p, type) => type ?? typeof(Button);
"Release";
#endif
+ var dir = Path.GetFullPath(
+ Path.Combine(
+ TestContext.CurrentContext.TestDirectory, "Xamarin.Forms.Controls.dll"));
var xamlg = new XamlGTask()
{
BuildEngine = new DummyBuildEngine(),
AssemblyName = "test",
Language = "C#",
XamlFiles = new[] { item },
- OutputFiles = new [] { new TaskItem(xamlOutputFile) },
- References = Path.GetFullPath(
- Path.Combine(
- Directory.GetCurrentDirectory(), "Xamarin.Forms.Controls.dll"))
+ OutputFiles = new[] { new TaskItem(xamlOutputFile) },
+ References = dir
};
var generator = new XamlGenerator(item, xamlg.Language, xamlg.AssemblyName, xamlOutputFile, xamlg.References, null);
var bindingType = XamlParser.GetElementType(new XmlType("http://xamarin.com/schemas/2014/forms", "Binding", null), null, null, out var ex);
Assert.That(ex, Is.Null);
Assert.That(bindingType, Is.EqualTo(typeof(BindingExtension)));
-
- var bindingTypeRef = new XmlType("http://xamarin.com/schemas/2014/forms", "Binding", null).GetTypeReference(ModuleDefinition.CreateModule("foo", ModuleKind.Dll), null);
+ var module = ModuleDefinition.CreateModule("foo", new ModuleParameters()
+ {
+ AssemblyResolver = new MockAssemblyResolver(),
+ Kind = ModuleKind.Dll,
+ });
+ var bindingTypeRef = new XmlType("http://xamarin.com/schemas/2014/forms", "Binding", null).GetTypeReference(module, null);
Assert.That(bindingType.FullName, Is.EqualTo("Xamarin.Forms.Xaml.BindingExtension"));
}
}
AssertExists (Path.Combine (intermediateDirectory, "XamlC.stamp"));
}
- [Test, ExpectedException (typeof(AssertionException))]
- public void InvalidXml ([Values (false, true)] bool sdkStyle)
+ [Test]
+ public void InvalidXml([Values(false, true)] bool sdkStyle)
{
- var project = NewProject (sdkStyle);
- project.Add (AddFile ("MainPage.xaml", "EmbeddedResource", "notxmlatall"));
- var projectFile = Path.Combine (tempDirectory, "test.csproj");
- project.Save (projectFile);
- RestoreIfNeeded (projectFile, sdkStyle);
- Build (projectFile);
+ var project = NewProject(sdkStyle);
+ project.Add(AddFile("MainPage.xaml", "EmbeddedResource", "notxmlatall"));
+ var projectFile = Path.Combine(tempDirectory, "test.csproj");
+ project.Save(projectFile);
+ RestoreIfNeeded(projectFile, sdkStyle);
+ Assert.Throws<AssertionException>(() => Build(projectFile));
}
[Test]
--- /dev/null
+using Mono.Cecil;
+using NUnit.Framework;
+using System.IO;
+
+namespace Xamarin.Forms.Xaml.UnitTests
+{
+ public class MockAssemblyResolver : BaseAssemblyResolver
+ {
+ public override AssemblyDefinition Resolve(AssemblyNameReference name)
+ {
+ AssemblyDefinition assembly;
+ var localPath = Path.GetFullPath(Path.Combine(TestContext.CurrentContext.TestDirectory, $"{name.Name}.dll"));
+ if (File.Exists(localPath))
+ assembly = AssemblyDefinition.ReadAssembly(localPath);
+ else
+ assembly = base.Resolve(name);
+ return assembly;
+ }
+ }
+}
\ No newline at end of file
}
[Test]
- [Ignore]
+ [Ignore(nameof(XamlCIs20TimesFasterThanXaml))]
public void XamlCIs20TimesFasterThanXaml ()
{
var swXamlC = new Stopwatch ();
}
[Test]
- [Ignore]
+ [Ignore(nameof(XamlCIsNotMuchSlowerThanCode))]
public void XamlCIsNotMuchSlowerThanCode ()
{
var swXamlC = new Stopwatch ();
<RootNamespace>Xamarin.Forms.Xaml.UnitTests</RootNamespace>
<AssemblyName>Xamarin.Forms.Xaml.UnitTests</AssemblyName>
<WarningLevel>4</WarningLevel>
- <NoWarn>0672;0219;0414</NoWarn>
+ <NoWarn>0672;0219;0414;CS0436</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<ProjectReference Include="..\Xamarin.Forms.Build.Tasks\Xamarin.Forms.Build.Tasks.csproj" />
</ItemGroup>
<ItemGroup>
- <PackageReference Include="NUnit" Version="2.6.4" />
+ <PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="Microsoft.Build.Locator" Version="1.2.6" />
+ <PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\Xamarin.Forms.Core.UnitTests\MockDispatcherProvider.cs">
using Xamarin.Forms.Build.Tasks;
using NUnit.Framework;
+using Xamarin.Forms.Xaml.UnitTests;
namespace Xamarin.Forms.XamlcUnitTests
{
[SetUp]
public void SetUp ()
{
- module = ModuleDefinition.CreateModule ("foo", ModuleKind.Dll);
+ module = ModuleDefinition.CreateModule("foo", new ModuleParameters()
+ {
+ AssemblyResolver = new MockAssemblyResolver(),
+ Kind = ModuleKind.Dll,
+ });
}
[Test]
using NUnit.Framework;
using System.Collections.Generic;
+using Xamarin.Forms.Xaml.UnitTests;
namespace Xamarin.Forms.XamlcUnitTests
{
[SetUp]
public void SetUp()
{
- module = ModuleDefinition.CreateModule("foo", ModuleKind.Dll);
+ module = ModuleDefinition.CreateModule("foo", new ModuleParameters()
+ {
+ AssemblyResolver = new MockAssemblyResolver(),
+ Kind = ModuleKind.Dll,
+ });
}
[Test]
-using System;
using System.Linq;
using Mono.Cecil;
using NUnit.Framework;
using System.Collections.Generic;
+using Xamarin.Forms.Xaml.UnitTests;
namespace Xamarin.Forms.XamlcUnitTests
{
}
[SetUp]
- public void SetUp ()
+ public void SetUp()
{
- module = ModuleDefinition.CreateModule ("foo", ModuleKind.Dll);
+ module = ModuleDefinition.CreateModule("foo", new ModuleParameters()
+ {
+ AssemblyResolver = new MockAssemblyResolver(),
+ Kind = ModuleKind.Dll,
+ });
}
[Test]
using NUnit.Framework.Constraints;
namespace Xamarin.Forms.Xaml.UnitTests
-{
+{
public class XamlParseExceptionConstraint : ExceptionTypeConstraint
{
bool haslineinfo;
int lineposition;
Func<string, bool> messagePredicate;
- XamlParseExceptionConstraint (bool haslineinfo) : base (typeof (XamlParseException))
+ XamlParseExceptionConstraint(bool haslineinfo) : base(typeof(XamlParseException))
{
this.haslineinfo = haslineinfo;
- DisplayName = "xamlparse";
}
- public XamlParseExceptionConstraint () : this (false)
+ public override string DisplayName => "xamlparse";
+
+ public XamlParseExceptionConstraint() : this(false)
{
}
this.messagePredicate = messagePredicate;
}
- public override bool Matches (object actual)
+ protected override bool Matches (object actual)
{
- this.actual = actual;
if (!base.Matches (actual))
return false;
var xmlInfo = ((XamlParseException)actual).XmlInfo;
return xmlInfo.LineNumber == linenumber && xmlInfo.LinePosition == lineposition;
}
- public override void WriteDescriptionTo (MessageWriter writer)
+ public override string Description
{
- base.WriteDescriptionTo (writer);
- if (haslineinfo)
- writer.Write (string.Format (" line {0}, position {1}", linenumber, lineposition));
- }
-
- public override void WriteActualValueTo (MessageWriter writer)
- {
- var ex = actual as XamlParseException;
- writer.WriteActualValue ((actual == null) ? null : actual.GetType ());
- if (ex != null) {
- if (ex.XmlInfo != null && ex.XmlInfo.HasLineInfo ())
- writer.Write (" line {0}, position {1}", ex.XmlInfo.LineNumber, ex.XmlInfo.LinePosition);
- else
- writer.Write (" no line info");
- writer.WriteLine (" ({0})", ex.Message);
- writer.Write (ex.StackTrace);
+ get
+ {
+ if (haslineinfo)
+ {
+ return string.Format($"{base.Description} line {linenumber}, position {lineposition}");
+ }
+ return base.Description;
}
}
+
+ //public override void WriteActualValueTo (MessageWriter writer)
+ //{
+ // var ex = actual as XamlParseException;
+ // writer.WriteActualValue ((actual == null) ? null : actual.GetType ());
+ // if (ex != null) {
+ // if (ex.XmlInfo != null && ex.XmlInfo.HasLineInfo ())
+ // writer.Write (" line {0}, position {1}", ex.XmlInfo.LineNumber, ex.XmlInfo.LinePosition);
+ // else
+ // writer.Write (" no line info");
+ // writer.WriteLine (" ({0})", ex.Message);
+ // writer.Write (ex.StackTrace);
+ // }
+ //}
}
}
\ No newline at end of file