public void ConstructorWithNameSetsUri() { var post = new Post("The long title"); Assert.That(post.Uri, Is.EqualTo(post.Title.ToUri())); Assert.That(post.Tags, Is.Not.Null); Assert.That(post.Comments, Is.Not.Null); }
public void SetUp() { Store = NewStore(); var asseta = new Post { Title = "Yeah", Body = "some content", Tags = new List<Tag> { new Tag("art") } }; var assetb = new Post { Title = "Okay", Body = "okay yeah that's right", Tags = new List<Tag> { new Tag("art") } }; var assetc = new Post { Title = "Trees", Body = "trees", Tags = new List<Tag> { new Tag("yeah") } }; using (var session = Store.OpenSession()) { session.Store(asseta); session.Store(assetb); session.Store(assetc); session.SaveChanges(); } }
public void MapsToViewModelWithSmartDates() { var locator = M<IServiceLocator>(); ServiceLocator.SetLocatorProvider(() => locator); var clock = M<ISystemClock>(); clock.Expect(c => c.Now()).Return(DateTime.Now).Repeat.Once(); locator.Expect(l => l.GetInstance<ISystemClock>()).Return(clock).Repeat.Once(); var post = new Post { Id = "some-id", Uri = "some-uri", Title = "Post title", Active = true, Created = new DateTime(2009, 8, 7, 6, 5, 4, DateTimeKind.Local), PublishFrom = new DateTime(2009, 1, 2, 3, 4, 5, DateTimeKind.Local) }; var model = Mapper.Map<Post, PostViewModel >(post); model.Active.ShouldBeTrue(); model.Title.ShouldEqual("Post title"); model.Id.ShouldEqual(post.Id); model.Uri.ShouldEqual(post.Uri); model.Created.ShouldEqual("07 aug 2009 06:05"); model.PublishFrom.ShouldEqual("02 jan 2009 03:04"); }
public void ActiveAndFutureIsNotPublished() { var locator = M<IServiceLocator>(); ServiceLocator.SetLocatorProvider(() => locator); var clock = M<ISystemClock>(); clock.Expect(c => c.Now()).Return(DateTime.Now); locator.Expect(l => l.GetInstance<ISystemClock>()).Return(clock); var post = new Post() { Active = true,PublishFrom=DateTime.Now.AddDays(3) }; var model = Mapper.Map<Post, PostViewModel>(post); model.IsPublished.ShouldBeFalse(); locator.VerifyAllExpectations(); clock.VerifyAllExpectations(); }
public void ActiveAndNoPublishDate() { var locator = M<IServiceLocator>(); ServiceLocator.SetLocatorProvider(() => locator); var clock = M<ISystemClock>(); clock.Expect(c => c.Now()).Return(DateTime.Now).Repeat.Never(); locator.Expect(l => l.GetInstance<ISystemClock>()).Return(clock).Repeat.Never(); var post = new Post() { Active = true, PublishFrom = null }; var model = Mapper.Map<Post, PostViewModel>(post); model.IsPublished.ShouldBeTrue(); locator.VerifyAllExpectations(); clock.VerifyAllExpectations(); }
public void DefaultConstructorMakesListsNotEmpty() { var post = new Post(); Assert.That(post.Tags, Is.Not.Null); Assert.That(post.Comments, Is.Not.Null); }