public void ShouldGoToShowForumOnCreateWithNoId() { var view = _repository.DynamicMock<IForumFormView>(); var provider = _repository.DynamicMock<IForumProvider>(); var loader = default(IEventRaiser); var creator = default(IEventRaiser); var input = new ForumInput {Name = "New Forum"}; var data = new ForumMapper().FromInput(input); var newId = 321; With.Mocks(_repository). ExpectingInSameOrder(() => { view.Load += null; loader = LastCall.IgnoreArguments().GetEventRaiser(); view.Create += null; creator = LastCall.IgnoreArguments().GetEventRaiser(); Expect.Call(view.IsPostBack).Return(true); Expect.Call(view.IsValid).Return(true); Expect.Call(view.Forum).Return(input); Expect.Call(provider.Create(data)).IgnoreArguments().Return(newId); Expect.Call(() => view.GoToShowForum(newId)); }). Verify(() => { new ForumFormPresenter(view, provider); loader.Raise(null, new EventArgs()); creator.Raise(null, new EventArgs()); }); }
public void ShouldMapForumEntityToInput() { // Arrange var data = new Core.Models.Forum {Id = 4132, Name = "ToInput name"}; // Act var input = new ForumMapper().ToInput(data); // Assert Assert.AreEqual(data.Id, input.Id); Assert.AreEqual(data.Name, input.Name); }
public void ShouldMapForumEntityFromInput() { // Arrange var input = new ForumInput {Id = 1423, Name = "FromInput name"}; // Act var data = new ForumMapper().FromInput(input); // Assert Assert.AreEqual(input.Id, data.Id); Assert.AreEqual(input.Name, data.Name); }
public void ShouldMapForumEntityToDisplay() { // Arrange var data = new Core.Models.Forum { Id = 1423, Name = "ToDisplay name", }; // Act var display = new ForumMapper().ToDisplay(data); // Assert Assert.AreEqual(data.Id, display.Id); Assert.AreEqual(data.Name, display.Name); }
public void ShouldShowForumOnLoadWithId() { var view = _repository.DynamicMock<IForumItemView>(); var provider = _repository.DynamicMock<IForumProvider>(); var loader = default(IEventRaiser); var id = 123; var data = new Core.Models.Forum {Id = id, Name = "Forum name"}; var display = new ForumMapper().ToDisplay(data); With.Mocks(_repository). ExpectingInSameOrder(() => { view.Load += null; loader = LastCall.IgnoreArguments().GetEventRaiser(); Expect.Call(view.IsPostBack).Return(false); Expect.Call(view.CurrentId).Return(id); Expect.Call(provider.Get(id)).Return(data); Expect.Call(view.Forum = display).IgnoreArguments(); }). Verify(() => { new ForumItemPresenter(view, provider); loader.Raise(null, new EventArgs()); }); }
public void ShouldShowPopulatedForumFormOnLoadWithId() { var view = _repository.DynamicMock<IForumFormView>(); var provider = _repository.DynamicMock<IForumProvider>(); var loader = default(IEventRaiser); var id = 1423; var data = new Core.Models.Forum { Id = id, Name = "Populated Forum" }; var input = new ForumMapper().ToInput(data); With.Mocks(_repository). ExpectingInSameOrder(() => { view.Load += null; loader = LastCall.IgnoreArguments().GetEventRaiser(); Expect.Call(view.IsPostBack).Return(false); Expect.Call(view.CurrentId).Return(id).Repeat.Any(); Expect.Call(provider.Get(id)).Return(data); Expect.Call(view.Forum = input); LastCall.IgnoreArguments(); SetupResult.For(view.Forum).Return(input); }). Verify(() => { new ForumFormPresenter(view, provider); loader.Raise(null, new EventArgs()); Assert.IsNotNull(view.Forum); Assert.AreEqual(data.Id, view.CurrentId); Assert.AreEqual(data.Name, view.Forum.Name); }); }
public void ShouldGoToShowForumOnUpdateWithId() { var view = _repository.DynamicMock<IForumFormView>(); var provider = _repository.DynamicMock<IForumProvider>(); var loader = default(IEventRaiser); var updater = default(IEventRaiser); var id = 3124; var data = new Core.Models.Forum {Id = id, Name = "Updated Forum"}; var input = new ForumMapper().ToInput(data); With.Mocks(_repository). ExpectingInSameOrder(() => { view.Load += null; loader = LastCall.IgnoreArguments().GetEventRaiser(); view.Update += null; updater = LastCall.IgnoreArguments().GetEventRaiser(); Expect.Call(view.IsPostBack).Return(true); Expect.Call(view.IsValid).Return(true); Expect.Call(view.Forum).Return(input); Expect.Call(provider.Update(data)).IgnoreArguments().Return(true); Expect.Call(() => view.GoToShowForum(id)); }). Verify(() => { new ForumFormPresenter(view, provider); loader.Raise(null, new EventArgs()); updater.Raise(null, new IdEventArgs {Id = id}); }); }
public virtual async Task ForumBoardManagement(JsonObtainer jsonObtainer, FORUMCONTROL forumControl) { //Get the json string json = await jsonObtainer.GetJsonStringAsync(); //map the obtained json to forum feed. ForumFeed forumFeed = Newtonsoft.Json.JsonConvert.DeserializeObject <ForumFeed>(json); //use the mapper class to get the general category ForumMapper forumMapper = new ForumMapper(); //Get the list of general categories from the forum feed. var generalCategories = forumMapper.GeneralCategories(forumFeed); //Get the list of web design categories var webCategories = forumMapper.WebCategories(forumFeed); //Get the mobile categories var mobileCategories = forumMapper.MobileCategories(forumFeed); //Finally set the datasource //Load the app categories var appCategories = forumMapper.AppCategories(forumFeed); //Get the database categories var databaseCategories = forumMapper.DatabaseCategories(forumFeed); //get the commmunity categories var communityCategories = forumMapper.CommunityCategories(forumFeed); foreach (var dat in webCategories) { string text = dat.latest; string formatted = Regex.Replace(text, @"<[^>]*>", ""); dat.latest = formatted; } foreach (var dat in generalCategories) { string text = dat.latest; string formatted = Regex.Replace(text, @"<[^>]*>", ""); dat.latest = formatted; } foreach (var dat in mobileCategories) { string text = dat.latest; string formatted = Regex.Replace(text, @"<[^>]*>", ""); dat.latest = formatted; } foreach (var dat in appCategories) { string text = dat.latest; string formatted = Regex.Replace(text, @"<[^>]*>", ""); dat.latest = formatted; } foreach (var dat in databaseCategories) { string text = dat.latest; string formatted = Regex.Replace(text, @"<[^>]*>", ""); dat.latest = formatted; } foreach (var dat in communityCategories) { string text = dat.latest; string formatted = Regex.Replace(text, @"<[^>]*>", ""); dat.latest = formatted; } forumControl.TheGeneralForumListBox.ItemsSource = generalCategories; forumControl.WebGeneralForumListBox.ItemsSource = webCategories; forumControl.MobileGeneralForumListBox.ItemsSource = mobileCategories; forumControl.AppGeneralForumListBox.ItemsSource = appCategories; forumControl.DatabaseGeneralForumListBox.ItemsSource = databaseCategories; forumControl.CommunityGeneralForumListBox.ItemsSource = communityCategories; }