This file contains hidden or 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
| require 'spec_helper' | |
| describe Users::OauthCallbacksController, "handle facebook authentication callback" do | |
| describe "#annonymous user" do | |
| context "when facebook email doesn't exist in the system" do | |
| before(:each) do | |
| stub_env_for_omniauth | |
| get :facebook |
This file contains hidden or 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
| [TestMethod] | |
| public void ToSlugShouldReturnJustSlug() | |
| { | |
| var value = "^&*#$Slug testing ?? @3 with--- some-tokens!."; | |
| var expected = "slug-testing-3-with-some-tokens"; | |
| var actual = value.ToSlug(); | |
| Assert.AreEqual(expected, actual); | |
| } |
This file contains hidden or 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
| public static string ToSlug(this string target) | |
| { | |
| var pattern = @"[^0-9a-zA-Z]+"; | |
| return Regex.Replace(target, pattern, "-") | |
| .Trim('-') | |
| .ToLowerInvariant(); | |
| } |
This file contains hidden or 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
| if (user.PostedPostCount > 1000 | |
| && user.LastActivityDate >= DateTime.Today.AddMonths(-3)) | |
| { | |
| // do something | |
| } |
This file contains hidden or 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
| // Is it Gold Partner? | |
| if (user.PostedPostCount > 1000 | |
| && user.LastActivityDate >= DateTime.Today.AddMonths(-3)) | |
| { | |
| // do something | |
| } |
This file contains hidden or 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
| if (user.IsGoldPartner()) | |
| { | |
| // do something | |
| } | |
| public class User | |
| { | |
| public int PostedPostCount { get; set; } | |
| public DateTime LastActivityDate { get; set; } | |
| public bool IsGoldPartner() |
This file contains hidden or 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
| public static class DateTimeExtensions | |
| { | |
| public static bool IsAfter(this DateTime current, DateTime value) | |
| { | |
| return current > value; | |
| } | |
| public static bool IsBefore(this DateTime current, DateTime value) | |
| { | |
| return current < value; |
This file contains hidden or 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
| [TestClass] | |
| public class DateTimeExtensionTest | |
| { | |
| [TestMethod] | |
| public void FiveMinAgoShouldBeBeforeCurrent() | |
| { | |
| var current = DateTime.Now; | |
| var fiveMinAgo = current.AddMinutes(-5); | |
| Assert.IsTrue(fiveMinAgo.IsBefore(current)); |
This file contains hidden or 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
| public class FormulaSample : ObservableBase | |
| { | |
| private decimal a; | |
| public decimal A | |
| { | |
| get { return a; } | |
| set | |
| { | |
| this.a = value; | |
| RaisePropertyChanged("A"); |
This file contains hidden or 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
| public class Formula<T> : INotifyPropertyChanged | |
| { | |
| public event PropertyChangedEventHandler PropertyChanged = delegate { }; | |
| private readonly Func<T> formula; | |
| private readonly INotifyPropertyChanged source; | |
| public Formula(INotifyPropertyChanged source, Func<T> formula, params string[] dependencyProperties) | |
| { | |
| this.source = source; |
OlderNewer