-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7ada9a5
commit 2609164
Showing
10 changed files
with
176 additions
and
51 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
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
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
63 changes: 63 additions & 0 deletions
63
src/Magpie/Magpie.Tests/ViewModels/EnrollmentViewModelTest.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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using Magpie.Tests.Mocks; | ||
using MagpieUpdater.Models; | ||
using MagpieUpdater.Services; | ||
using MagpieUpdater.ViewModels; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace Magpie.Tests.ViewModels | ||
{ | ||
[TestClass] | ||
public class EnrollmentViewModelTest | ||
{ | ||
[TestMethod] | ||
public void PropertiesAreInitializedCorrectly() | ||
{ | ||
var channel = new MockChannel(1, build: "Test Build", enrollmentEula: "www.example.com"); | ||
var enrollment = new Enrollment(channel); | ||
var appInfo = new AppInfo("testString") {AppIconPath = "iconPath"}; | ||
var sut = new EnrollmentViewModel(enrollment, appInfo); | ||
Assert.AreEqual("Test Build", sut.ChannelName); | ||
Assert.AreEqual("www.example.com", sut.EnrollmentEulaUrl); | ||
Assert.AreEqual("iconPath", sut.AppIconPath); | ||
} | ||
|
||
[TestMethod] | ||
public void CanNotEnrollWithInvalidEmail() | ||
{ | ||
var sut = new EnrollmentViewModel(new Enrollment(new Channel()), new AppInfo("testString")) | ||
{ | ||
EmailAddress = "test" | ||
}; | ||
Assert.IsFalse(sut.EnrollCommand.CanExecute(null)); | ||
sut.EmailAddress = null; | ||
Assert.IsFalse(sut.EnrollCommand.CanExecute(null)); | ||
sut.EmailAddress = string.Empty; | ||
Assert.IsFalse(sut.EnrollCommand.CanExecute(null)); | ||
sut.EmailAddress = "test@"; | ||
Assert.IsFalse(sut.EnrollCommand.CanExecute(null)); | ||
} | ||
|
||
[TestMethod] | ||
public void CanEnrollWithValidEmail() | ||
{ | ||
var sut = new EnrollmentViewModel(new Enrollment(new Channel()), new AppInfo("testString")) | ||
{ | ||
EmailAddress = "[email protected]" | ||
}; | ||
Assert.IsTrue(sut.EnrollCommand.CanExecute(null)); | ||
} | ||
|
||
[TestMethod] | ||
public void ExecuteEnrollCommand_FillsInEnrollment() | ||
{ | ||
var enrollment = new Enrollment(new Channel()); | ||
var sut = new EnrollmentViewModel(enrollment, new AppInfo("testString")) | ||
{ | ||
EmailAddress = "[email protected]" | ||
}; | ||
sut.EnrollCommand.Execute(null); | ||
Assert.IsTrue(enrollment.IsEnrolled); | ||
Assert.AreEqual("[email protected]", enrollment.Email); | ||
} | ||
} | ||
} |
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
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
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