-
-
Save hatelove/c2f4e84e6043f7e84121 to your computer and use it in GitHub Desktop.
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
using System; | |
using Microsoft.VisualStudio.TestTools.UnitTesting; | |
using NSubstitute; | |
namespace MvpRenewTest | |
{ | |
[TestClass] | |
public class MvpTests | |
{ | |
//[TestMethod] | |
//public void TestMethod_MVP現有類別不在指定類別內並且不是十月份MVP可以自動延長一年() | |
//{ | |
// var oldMVPCategory = new[] | |
// { | |
// "Consumer Security", | |
// "Windows Consumer Apps", | |
// "Windows Experience", | |
// "Windows Phone", | |
// "Surface", | |
// "ID@Xbox", | |
// "Xbox", | |
// "Bing Ads", | |
// "Access", | |
// "Excel", | |
// "Macintosh", | |
// "Office System", | |
// "OneNote", | |
// "Outlook", | |
// "PowerPoint", | |
// "Publisher", | |
// "Visio", | |
// "Word" | |
// }; | |
// var exceptionMonth = 10; | |
// var mvp = new Mvp(); | |
// var target = mvp.CurrentCategory.Except(oldMVPCategory); | |
// var expected = "AutoRenew"; | |
// var actual = mvp.AutoRenewCheck(target, exceptionMonth, mvp.WinnerMonth); | |
// Assert.AreEqual(expected, actual); | |
//} | |
[TestMethod] | |
public void Test_AutoRenew_Joey_Should_be_AutoRenew() | |
{ | |
IProfileDao profileDao = Substitute.For<IProfileDao>(); | |
var target = new Mvp("JoeyChen") { ProfileDao = profileDao }; | |
profileDao.GetMvpStatus("JoeyChen").Returns(Tuple.Create(1, "ASP.NET")); | |
var exceptionMonth = 10; | |
var excludeCategory = new string[] { | |
"Consumer Security", | |
"Windows Consumer Apps", | |
"Windows Experience", | |
"Windows Phone", | |
"Surface", | |
"ID@Xbox", | |
"Xbox", | |
"Bing Ads", | |
"Access", | |
"Excel", | |
"Macintosh", | |
"Office System", | |
"OneNote", | |
"Outlook", | |
"PowerPoint", | |
"Publisher", | |
"Visio", | |
"Word" | |
}; | |
bool isAutoRenew = target.CheckAutoRenew(exceptionMonth, excludeCategory); | |
Assert.IsTrue(isAutoRenew); | |
} | |
[TestMethod] | |
public void Test_AutoRenew_Bill_is_Oct_Mvp_Should_not_be_AutoRenew() | |
{ | |
IProfileDao profileDao = Substitute.For<IProfileDao>(); | |
var target = new Mvp("Bill") { ProfileDao = profileDao }; | |
profileDao.GetMvpStatus("Bill").Returns(Tuple.Create(10, "ASP.NET")); | |
var exceptionMonth = 10; | |
var excludeCategory = new string[] { | |
"Consumer Security", | |
"Windows Consumer Apps", | |
"Windows Experience", | |
"Windows Phone", | |
"Surface", | |
"ID@Xbox", | |
"Xbox", | |
"Bing Ads", | |
"Access", | |
"Excel", | |
"Macintosh", | |
"Office System", | |
"OneNote", | |
"Outlook", | |
"PowerPoint", | |
"Publisher", | |
"Visio", | |
"Word" | |
}; | |
bool isAutoRenew = target.CheckAutoRenew(exceptionMonth, excludeCategory); | |
Assert.IsFalse(isAutoRenew); | |
} | |
[TestMethod] | |
public void Test_AutoRenew_Dolly_is_Excel_Mvp_Should_not_be_AutoRenew() | |
{ | |
IProfileDao profileDao = Substitute.For<IProfileDao>(); | |
var target = new Mvp("Dolly") { ProfileDao = profileDao }; | |
profileDao.GetMvpStatus("Dolly").Returns(Tuple.Create(1, "Excel")); | |
var exceptionMonth = 10; | |
var excludeCategory = new string[] { | |
"Consumer Security", | |
"Windows Consumer Apps", | |
"Windows Experience", | |
"Windows Phone", | |
"Surface", | |
"ID@Xbox", | |
"Xbox", | |
"Bing Ads", | |
"Access", | |
"Excel", | |
"Macintosh", | |
"Office System", | |
"OneNote", | |
"Outlook", | |
"PowerPoint", | |
"Publisher", | |
"Visio", | |
"Word" | |
}; | |
bool isAutoRenew = target.CheckAutoRenew(exceptionMonth, excludeCategory); | |
Assert.IsFalse(isAutoRenew); | |
} | |
} | |
internal class Mvp | |
{ | |
private string _name; | |
public Mvp(string name) | |
{ | |
this._name = name; | |
} | |
public IProfileDao ProfileDao { get; internal set; } | |
internal bool CheckAutoRenew(int exceptionMonth, string[] excludeCategory) | |
{ | |
throw new NotImplementedException(); | |
} | |
} | |
public interface IProfileDao | |
{ | |
Tuple<int, string> GetMvpStatus(string id); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment