-
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.
Merge pull request #6 from vgertman/enrollment
Refactor and add tests
- Loading branch information
Showing
25 changed files
with
511 additions
and
28 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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); | ||
} | ||
} | ||
} |
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
namespace MagpieUpdater.Models | ||
{ | ||
public class Enrollment | ||
{ | ||
public Channel Channel { get; private set; } | ||
public bool IsRequired { get; internal set; } | ||
public bool IsEnrolled { get; internal set; } | ||
public string Email { get; internal set; } | ||
|
||
public Enrollment(Channel channel) | ||
{ | ||
Channel = channel; | ||
} | ||
} | ||
} |
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
Oops, something went wrong.