-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move to xunit 2 where possible (#76)
- Loading branch information
1 parent
127d1ed
commit 4cd20f2
Showing
6 changed files
with
187 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
200 changes: 120 additions & 80 deletions
200
src/Tests/FeatureToggle.WindowsStore.Tests/ApplicationResourcesSettingsProviderShould.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,115 +1,155 @@ | ||
// These tests are commented out until I figure out how to have app.xaml in this test project | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Windows.UI.Xaml; | ||
using FeatureToggle.Providers; | ||
using FeatureToggle.Toggles; | ||
using Xunit; | ||
|
||
namespace FeatureToggle.WindowsStore.Tests | ||
{ | ||
[Trait("category", "Threaded")] | ||
public class ApplicationResourcesSettingsProviderShould | ||
{ | ||
[Fact] | ||
public async void ReadBooleanTrue() | ||
{ | ||
var result = false; | ||
|
||
//using System; | ||
//using FeatureToggle.Providers; | ||
//using FeatureToggle.Toggles; | ||
//using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; | ||
//using Microsoft.VisualStudio.TestPlatform.UnitTestFramework.AppContainer; | ||
//using Assert = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.Assert; | ||
var sut = new ApplicationResourcesSettingsProvider(); | ||
|
||
//namespace FeatureToggle.WindowsStore.Tests | ||
//{ | ||
// [TestClass] | ||
// public class ApplicationResourcesSettingsProviderShould | ||
// { | ||
// [UITestMethod] | ||
// public void ReadBooleanTrue() | ||
// { | ||
// var result = false; | ||
|
||
// var sut = new ApplicationResourcesSettingsProvider(); | ||
|
||
// result = sut.EvaluateBooleanToggleValue(new BooleanTrue()); | ||
await RunOn.Dispatcher(() => | ||
{ | ||
Application.Current.Resources["FeatureToggle.BooleanTrue"] = true; | ||
result = sut.EvaluateBooleanToggleValue(new BooleanTrue()); | ||
}); | ||
|
||
// Assert.IsTrue(result); | ||
// } | ||
Assert.True(result); | ||
} | ||
|
||
|
||
// [UITestMethod] | ||
// public void ReadBooleanFalse() | ||
// { | ||
// var result = true; | ||
[Fact] | ||
public async void ReadBooleanFalse() | ||
{ | ||
var result = true; | ||
|
||
// var sut = new ApplicationResourcesSettingsProvider(); | ||
var sut = new ApplicationResourcesSettingsProvider(); | ||
|
||
// result = sut.EvaluateBooleanToggleValue(new BooleanFalse()); | ||
await RunOn.Dispatcher(() => | ||
{ | ||
Application.Current.Resources["FeatureToggle.BooleanFalse"] = false; | ||
result = sut.EvaluateBooleanToggleValue(new BooleanFalse()); | ||
}); | ||
|
||
// Assert.IsFalse(result); | ||
// } | ||
|
||
Assert.False(result); | ||
} | ||
|
||
|
||
// [UITestMethod] | ||
// public void ErrorWhenKeyNotInConfig() | ||
// { | ||
// Exception expectedEx = null; | ||
|
||
// try | ||
// { | ||
// new ApplicationResourcesSettingsProvider().EvaluateBooleanToggleValue(new NotInConfig()); | ||
// } | ||
// catch (Exception ex) | ||
// { | ||
// expectedEx = ex; | ||
// } | ||
|
||
[Fact] | ||
public async void ErrorWhenKeyNotInConfig() | ||
{ | ||
Exception expectedEx = null; | ||
|
||
// Assert.IsNotNull(expectedEx, "Exception expected"); | ||
// } | ||
try | ||
{ | ||
await RunOn.Dispatcher(() => | ||
{ | ||
new ApplicationResourcesSettingsProvider().EvaluateBooleanToggleValue(new NotInConfig()); | ||
}); | ||
} | ||
catch (Exception ex) | ||
{ | ||
expectedEx = ex; | ||
} | ||
|
||
|
||
// [UITestMethod] | ||
// public void ReadDate() | ||
// { | ||
// var result = DateTime.MaxValue; | ||
Assert.True(expectedEx.Message.EndsWith("was not found in Application.Current.Resources")); | ||
} | ||
|
||
// var sut = new ApplicationResourcesSettingsProvider(); | ||
|
||
// result = sut.EvaluateDateTimeToggleValue(new SimpleToggle()); | ||
[Fact] | ||
public async void ReadDate() | ||
{ | ||
var result = DateTime.MaxValue; | ||
|
||
// Assert.AreEqual(new DateTime(2000, 1, 1, 23, 22, 21), result); | ||
// } | ||
var sut = new ApplicationResourcesSettingsProvider(); | ||
|
||
await RunOn.Dispatcher(() => | ||
{ | ||
Application.Current.Resources["FeatureToggle.SimpleToggle"] = "01-Feb-2000 23:22:21"; | ||
result = sut.EvaluateDateTimeToggleValue(new SimpleToggle()); | ||
}); | ||
|
||
// [UITestMethod] | ||
// public void ReadDatePeriod() | ||
// { | ||
// var result = Tuple.Create(DateTime.MinValue, DateTime.MaxValue); | ||
Assert.Equal(new DateTime(2000, 2, 1, 23, 22, 21), result); | ||
} | ||
|
||
// var sut = new ApplicationResourcesSettingsProvider(); | ||
|
||
// result = sut.EvaluateTimePeriod(new PeriodToggle()); | ||
[Fact] | ||
public async void ReadDatePeriod() | ||
{ | ||
var result = Tuple.Create(DateTime.MinValue, DateTime.MaxValue); | ||
|
||
// Assert.AreEqual(new DateTime(2000, 1, 1, 23, 22, 21), result.Item1); | ||
// Assert.AreEqual(new DateTime(2001, 1, 1, 23, 22, 21), result.Item2); | ||
// } | ||
var sut = new ApplicationResourcesSettingsProvider(); | ||
|
||
await RunOn.Dispatcher(() => | ||
{ | ||
Application.Current.Resources["FeatureToggle.PeriodToggle"] = "01-Jan-2000 23:22:21 | 01-Jan-2001 23:22:21"; | ||
result = sut.EvaluateTimePeriod(new PeriodToggle()); | ||
}); | ||
|
||
Assert.Equal(new DateTime(2000, 1, 1, 23, 22, 21), result.Item1); | ||
Assert.Equal(new DateTime(2001, 1, 1, 23, 22, 21), result.Item2); | ||
} | ||
|
||
// private class BooleanTrue : SimpleFeatureToggle | ||
// { | ||
// } | ||
|
||
// private class BooleanFalse : SimpleFeatureToggle | ||
// { | ||
// } | ||
[Fact] | ||
public async void ReadDaysOfWeek() | ||
{ | ||
List<DayOfWeek> result = null; | ||
|
||
// private class NotInConfig : SimpleFeatureToggle | ||
// { | ||
// } | ||
|
||
// private class SimpleToggle : SimpleFeatureToggle | ||
// { | ||
// } | ||
var sut = new ApplicationResourcesSettingsProvider(); | ||
|
||
await RunOn.Dispatcher(() => | ||
{ | ||
Application.Current.Resources["FeatureToggle.DaysToggle"] = "Wednesday, Saturday"; | ||
result = sut.GetDaysOfWeek(new DaysToggle()).ToList(); | ||
}); | ||
|
||
// private class PeriodToggle : SimpleFeatureToggle | ||
// { | ||
// } | ||
|
||
// } | ||
Assert.Equal(DayOfWeek.Wednesday, result[0]); | ||
Assert.Equal(DayOfWeek.Saturday, result[1]); | ||
Assert.Equal(2, result.Count); | ||
} | ||
|
||
|
||
|
||
//} | ||
|
||
private class BooleanTrue : SimpleFeatureToggle | ||
{ | ||
} | ||
|
||
private class BooleanFalse : SimpleFeatureToggle | ||
{ | ||
} | ||
|
||
private class NotInConfig : SimpleFeatureToggle | ||
{ | ||
} | ||
|
||
private class SimpleToggle : SimpleFeatureToggle | ||
{ | ||
} | ||
|
||
|
||
private class PeriodToggle : SimpleFeatureToggle | ||
{ | ||
} | ||
|
||
private class DaysToggle : EnabledOnDaysOfWeekFeatureToggle | ||
{ | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Windows.UI.Core; | ||
|
||
namespace FeatureToggle.WindowsStore.Tests | ||
{ | ||
public static class RunOn | ||
{ | ||
public static async Task Dispatcher(Action a, int timeOut = 5000) | ||
{ | ||
await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, a.Invoke); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="xunit" version="2.0.0" targetFramework="win81" /> | ||
<package id="xunit.abstractions" version="2.0.0" targetFramework="win81" /> | ||
<package id="xunit.assert" version="2.0.0" targetFramework="win81" /> | ||
<package id="xunit.core" version="2.0.0" targetFramework="win81" /> | ||
<package id="xunit.extensibility.core" version="2.0.0" targetFramework="win81" /> | ||
<package id="xunit.runner.visualstudio" version="2.0.0" targetFramework="win81" /> | ||
</packages> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters