public void IncludeConferenceWithOneTrackSuccessfully() { var stringTalkList = new List <string>(); stringTalkList.Add("Rails Magic 60min"); stringTalkList.Add("Ruby on Rails: Why We Should Move On 60min"); stringTalkList.Add("Clojure Ate Scala(on my project) 45min"); stringTalkList.Add("Programming in the Boondocks of Seattle 30min"); stringTalkList.Add("Ruby vs.Clojure for Back - End Development 30min"); stringTalkList.Add("Ruby on Rails Legacy App Maintenance 60min"); stringTalkList.Add("A World Without HackerNews 30min"); stringTalkList.Add("User Interface CSS in Rails Apps 30min"); var talkService = new TalkService(); var talks = new List <Talk>(); foreach (var item in stringTalkList) { talks.Add(talkService.IncludeTalk(item)); } var service = new ConferenceService(); var conference = service.ScheduleTalks(talks); Assert.IsTrue(conference != null && conference.Tracks.Count == 1 && string.IsNullOrWhiteSpace(service.Error)); }
public void IncludeConferenceWithOnlyMorningSessionTrackSuccessfully() { var stringTalkList = new List <string>(); stringTalkList.Add("Clojure Ate Scala(on my project) 45min"); stringTalkList.Add("Programming in the Boondocks of Seattle 30min"); stringTalkList.Add("Ruby vs.Clojure for Back - End Development 30min"); stringTalkList.Add("User Interface CSS in Rails Apps 30min"); var talkService = new TalkService(); var talks = new List <Talk>(); foreach (var item in stringTalkList) { talks.Add(talkService.IncludeTalk(item)); } var service = new ConferenceService(); var conference = service.ScheduleTalks(talks); Assert.IsTrue(conference != null && conference.Tracks.Count == 1 && conference.Tracks[0].HasNetworking == false && conference.Tracks[0].MorningTalks.Count > 0 && conference.Tracks[0].AfternoonTalks.Count == 0 && string.IsNullOrWhiteSpace(service.Error)); }
public void DontVisualizeScheduleWithNullConference() { var service = new ConferenceService(); var schedule = service.VisualizeSchedule(null); Assert.IsTrue(schedule == null && !string.IsNullOrWhiteSpace(service.Error)); }
public SessionViewModel( ConferenceService conferenceService, SessionSelectionModel sessionSelection) { _conferenceService = conferenceService; _sessionSelection = sessionSelection; }
public static ConferenceInfo PopulateConfereceData(Table table) { var svc = new ConferenceService(BuildEventBus()); var conference = BuildInternalConferenceInfo(table); svc.CreateConference(conference); svc.Publish(conference.Id); // publish seats ICollection <SeatType> createdSeats = CreateSeats(table); foreach (var seat in createdSeats) { svc.CreateSeat(conference.Id, seat); } var created = MessageLogHelper.CollectEvents <AvailableSeatsChanged>(conference.Id, createdSeats.Count); if (!created) { throw new TimeoutException("Conference creation error"); } // Update the confInfo with the created seats conference.Seats.AddRange(createdSeats); return(conference); }
protected override void OnInitialized() { editContext = new EditContext(Report); editContext.OnFieldChanged += HandleFieldChanged; speakers = SpeakerService.GetSpeakers().ToImmutableArray(); conferences = ConferenceService.GetConferences().ToImmutableArray(); if (Report.Speakers is { })
public IHttpActionResult Get(int id) { ConferenceService conferenceService = CreateConferenceService(); var conference = conferenceService.GetConferenceById(id); return(Ok(conference)); }
public DeleteConferenceViewModel(bool modelState, Conference conference, ConferenceService service) { if (modelState) { try { Status = CheckEntity(service, conference); } catch (InternetException ex) { Message = ex.Message; Status = false; return; } catch (DatabaseException ex) { Message = ex.Message; Status = false; return; } Message = " Delete successful!\n"; Status = true; } else { Message = " Invalid request!\n"; Status = false; } }
public void VisualizeScheduleSuccessfully() { var service = new ConferenceService(); var conference = service.ScheduleTalks(DefaultTalks); var schedule = service.VisualizeSchedule(conference); Assert.IsTrue(!string.IsNullOrWhiteSpace(schedule.ToString()) && string.IsNullOrWhiteSpace(service.Error)); }
public void DontIncludeConferenceWithoutTalks() { var service = new ConferenceService(); var talksCountZero = new List <Talk>(); var conference = service.ScheduleTalks(talksCountZero); Assert.IsTrue(conference == null && !string.IsNullOrWhiteSpace(service.Error)); }
private void InitaliseServices() { var repository = new ConferenceService(); this.RegisterServiceInstance <IConferenceService>(repository); this.RegisterServiceInstance <ITwitterSearchProvider>(new TwitterSearchProvider()); }
private void InitialiseServices() { var repository = new ConferenceService(); Cirrious.MvvmCross.Plugins.File.PluginLoader.Instance.EnsureLoaded(); Mvx.RegisterSingleton <IConferenceService>(repository); Mvx.RegisterSingleton <ITwitterSearchProvider>(new TwitterSearchProvider()); }
public async Task ItGetsFeaturedConferences() { // Arrange // Act await Controller.GetFeatured(); // Assert ConferenceService.Verify(x => x.GetFeatured(), Times.Once()); }
public async Task ItGetsConferences() { // Arrange // Act await Controller.GetAll(0, 1, nameof(Direction.Asc)); // Assert ConferenceService.Verify(x => x.GetAll(0, 1, nameof(Direction.Asc)), Times.Once()); }
public void Setup() { // 初始化会议数据库 using (var context = new ConferenceContext(this._dbName)) { if (context.Database.Exists()) { context.Database.Delete(); } context.Database.Create(); } // 模拟事件总线 this._busEvents = new List <IEvent>(); var busMock = new Mock <IEventBus>(); busMock.Setup(b => b.Publish(It.IsAny <Envelope <IEvent> >())) .Callback <Envelope <IEvent> >(e => this._busEvents.Add(e.Body)); busMock.Setup(b => b.Publish(It.IsAny <IEnumerable <Envelope <IEvent> > >())) .Callback <IEnumerable <Envelope <IEvent> > >(es => this._busEvents.AddRange(es.Select(e => e.Body))); this._service = new ConferenceService(busMock.Object, this._dbName); this._conference = new ConferenceInfo() { OwnerEmail = "*****@*****.**", OwnerName = "test owner", AccessCode = "qwerty", Name = "test conference", Description = "test conference description", Location = "redmond", Slug = "test", StartDate = DateTime.UtcNow, EndDate = DateTime.UtcNow.Add(TimeSpan.FromDays(2)), Seats = { new SeatType() { Name = "general", Description = "general description", Price = 100, Quantity = 10 } } }; this._service.CreateConference(this._conference); this._placed = new OrderPlaced() { ConferenceId = Guid.NewGuid(), SourceId = Guid.NewGuid(), AccessCode = "asdf" }; this._eventHandler = new OrderEventHandler(() => new ConferenceContext(_dbName)); this._eventHandler.Handle(_placed); }
public void IncludeConferenceWithTwoTracksSuccessfully() { var service = new ConferenceService(); var conference = service.ScheduleTalks(DefaultTalks); Assert.IsTrue(conference != null && conference.Tracks.Count == 2 && string.IsNullOrWhiteSpace(service.Error)); }
public async Task ItGetsConference() { // Arrange // Act await Controller.GetBySlug(_slug); // Assert ConferenceService.Verify(x => x.Get(_slug), Times.Once()); }
protected override void OnActionExecuting(ActionExecutingContext filterContext) { base.OnActionExecuting(filterContext); if (_conferenceService == null) { string appDataPath = Path.Combine(HttpContext.Request.PhysicalApplicationPath, "App_Data"); _conferenceService = new ConferenceService(appDataPath); } }
public ConferenceServiceTestBase() { Cache = new Mock <ICacheManager>(); Repository = new Mock <ISpeakerMeetRepository>(); Repository.Setup(x => x.List(It.IsAny <ConferenceSpecification>())) .ReturnsAsync(new List <Conference>()); Service = new ConferenceService(Cache.Object, Repository.Object); }
public ScientistAddsConferenceViewModel(ScientistModel selectedScientist) { SelectedScientist = selectedScientist; List <Conference> conferences = ConferenceService.GetConferences(); foreach (Conference c in conferences) { Conferences.Add(new ConferenceModel(c)); } }
public SessionViewModel(int sessionId) { _conferenceService = new ConferenceService(); _id = sessionId; var session = _conferenceService.LoadSession(_id); _speaker = session.Speaker; _title = session.Title; }
public async Task <ActionResult> SpeakerDetails(string speakerName) { if (speakerName.Contains("tein")) { return(View("Error")); } var speaker = await ConferenceService.GetSpeakerByName(speakerName); return(View(speaker)); }
private async void LoadSpeakers(object sender, RoutedEventArgs e) { _loadingDone = false; var speakers = await ConferenceService.GetSpeakers(); var speakerViewModels = from speaker in speakers select new SpeakerViewModel(speaker); lstSpeakers.ItemsSource = speakerViewModels.ToArray(); _loadingDone = true; }
public async Task GivenException_ThenBadRequestResult() { // Arrange ConferenceService.Setup(x => x.Get(_slug)).Throws(new Exception()); // Act var result = await Controller.GetBySlug(_slug); // Assert Assert.IsAssignableFrom <BadRequestObjectResult>(result.Result); }
public async Task GivenEntityNotFoundException_ThenNotFoundResult() { // Arrange ConferenceService.Setup(x => x.Get(_id)).Throws(new EntityNotFoundException()); // Act var result = await Controller.Get(_id); // Assert Assert.IsAssignableFrom <NotFoundObjectResult>(result.Result); }
public static ConferenceInfo FindConference(string conferenceSlug) { var svc = new ConferenceService(BuildEventBus()); var conference = svc.FindConference(conferenceSlug); if (null != conference) { if (conference.Seats.Count == 0) svc.FindSeatTypes(conference.Id).ToList().ForEach(s => conference.Seats.Add(s)); } return conference; }
public ConferenceAddsReportViewModel(Window window, ConferenceModel selectedConference) { Window = window; List <Report> reports = ConferenceService.GetReports(selectedConference.Conference); foreach (Report r in reports) { Reports.Add(new ReportModel(r)); } SelectedConference = selectedConference; }
public async Task GivenException_ThenBadRequestResult() { // Arrange ConferenceService.Setup(x => x.GetAll(0, 1, nameof(Direction.Desc))).Throws(new Exception()); // Act var result = await Controller.GetAll(0, 1, nameof(Direction.Desc)); // Assert Assert.IsAssignableFrom <BadRequestObjectResult>(result.Result); }
public ConferenceViewModel() { _conferenceService = new ConferenceService(); foreach (var session in _conferenceService.GetSessions()) { _sessions.Add(new SessionHeaderViewModel { Id = session.Id, Title = session.Title }); } }
public given_no_conference() { using (var context = new ConferenceContext(dbName)) { if (context.Database.Exists()) context.Database.Delete(); context.Database.CreateIfNotExists(); } this.bus = new MemoryEventBus(); this.service = new ConferenceService(this.bus, this.dbName); }
public async Task GivenEntityNotFoundException_ThenItLogsWarning() { // Arrange var ex = new EntityNotFoundException(); ConferenceService.Setup(x => x.Get(_id)).Throws(ex); // Act await Controller.Get(_id); // Assert Logger.Verify(x => x.LogWarning(ex, ex.Message), Times.Once()); }
public async Task GivenException_ThenItLogsError() { // Arrange var ex = new Exception(); ConferenceService.Setup(x => x.Get(_slug)).Throws(ex); // Act await Controller.GetBySlug(_slug); // Assert Logger.Verify(x => x.LogError(ex, ex.Message), Times.Once()); }
public static void CreateSeats(string conferenceSlug, Table table) { var svc = new ConferenceService(BuildEventBus()); var conference = FindConference(conferenceSlug); foreach (var row in table.Rows) { svc.CreateSeat(conference.Id, new SeatType { Name = row["Name"], Description = row["Description"], Quantity = int.Parse(row["Quantity"]), Price = decimal.Parse(row["Price"]) }); } }
public given_no_conference() { using (var context = new ConferenceContext(dbName)) { if (context.Database.Exists()) context.Database.Delete(); context.Database.Create(); } this.busEvents = new List<IEvent>(); var busMock = new Mock<IEventBus>(); busMock.Setup(b => b.Publish(It.IsAny<Envelope<IEvent>>())).Callback<Envelope<IEvent>>(e => busEvents.Add(e.Body)); busMock.Setup(b => b.Publish(It.IsAny<IEnumerable<Envelope<IEvent>>>())).Callback<IEnumerable<Envelope<IEvent>>>(es => busEvents.AddRange(es.Select(e => e.Body))); this.service = new ConferenceService(busMock.Object, this.dbName); }
public static ConferenceInfo PopulateConfereceData(Table table) { string conferenceSlug = Slug.CreateNew().Value; var svc = new ConferenceService(BuildEventBus()); var conference = BuildConferenceInfo(table, conferenceSlug); svc.CreateConference(conference); svc.Publish(conference.Id); Registration.ReadModel.Conference published = null; while(published == null || !published.IsPublished || published.Seats.Count != table.Rows.Count) { published = RegistrationHelper.FindConference(conference.Id); Thread.Sleep(100); } return conference; }
public static ConferenceInfo PopulateConfereceData(Table table) { var svc = new ConferenceService(BuildEventBus()); var conference = BuildInternalConferenceInfo(table); svc.CreateConference(conference); svc.Publish(conference.Id); // publish seats ICollection<SeatType> createdSeats = CreateSeats(table); foreach (var seat in createdSeats) { svc.CreateSeat(conference.Id, seat); } var created = MessageLogHelper.CollectEvents<AvailableSeatsChanged>(conference.Id, createdSeats.Count); if(!created) throw new TimeoutException("Conference creation error"); // Update the confInfo with the created seats conference.Seats.AddRange(createdSeats); return conference; }
public static void Register(HttpConfiguration config) { config.Formatters.JsonFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html")); // Web API configuration and services // Configure Web API to use only bearer token authentication. // Web API routes config.MapHttpAttributeRoutes(); var cors = new EnableCorsAttribute("*", "*", "*"); config.EnableCors(cors); config.Filters.Add(new ExceptionHandlingAttribute()); config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); var container = new UnityContainer(); try { // repositories used by the application container.RegisterType<ConferenceRegistrationDbContext>(new TransientLifetimeManager(), new InjectionConstructor("ConferenceRegistration")); container.RegisterType<PaymentsReadDbContext>(new TransientLifetimeManager(), new InjectionConstructor("Payments")); var cache = new MemoryCache("ReadModel"); container.RegisterType<IOrderDao, OrderDao>(); container.RegisterType<IConferenceDao, CachingConferenceDao>( new ContainerControlledLifetimeManager(), new InjectionConstructor(new ResolvedParameter<ConferenceDao>(), cache)); container.RegisterType<IPaymentDao, PaymentDao>(); // configuration specific settings var serializer = new JsonTextSerializer(); container.RegisterInstance<ITextSerializer>(serializer); container.RegisterType<IBlobStorage, SqlBlobStorage>(new ContainerControlledLifetimeManager(), new InjectionConstructor("BlobStorage")); container.RegisterType<Infrastructure.Sql.Messaging.IMessageSender, MessageSender>( "Commands", new TransientLifetimeManager(), new InjectionConstructor(Database.DefaultConnectionFactory, "SqlBus", "SqlBus.Commands")); container.RegisterType<ICommandBus, Infrastructure.Sql.Messaging.CommandBus>( new ContainerControlledLifetimeManager(), new InjectionConstructor(new ResolvedParameter<Infrastructure.Sql.Messaging.IMessageSender>("Commands"), serializer)); config.DependencyResolver = new UnityResolver(container); IEventBus eventBus = null; //#if LOCAL eventBus = new Infrastructure.Sql.Messaging.EventBus(new MessageSender(Database.DefaultConnectionFactory, "SqlBus", "SqlBus.Events"), serializer); //#else // var settings = InfrastructureSettings.Read(HttpContext.Current.Server.MapPath(@"~\bin\Settings.xml")).ServiceBus; // if (!MaintenanceMode.IsInMaintainanceMode) // { // new ServiceBusConfig(settings).Initialize(); // } // eventBus = new Infrastructure.Azure.Messaging.EventBus(new TopicSender(settings, "conference/events"), new StandardMetadataProvider(), serializer); //#endif container.RegisterInstance<IEventBus>(eventBus); var conferenceService = new ConferenceService(eventBus); container.RegisterInstance<ConferenceService>(conferenceService); } catch { container.Dispose(); throw; } }
public ConferenceController(IConferenceDao dao, ConferenceService conferenceService) { this._dao = dao; _tracer = GlobalConfiguration.Configuration.Services.GetTraceWriter(); service = conferenceService; }
public given_an_existing_conference_with_a_seat() { using (var context = new ConferenceContext(dbName)) { if (context.Database.Exists()) context.Database.Delete(); context.Database.CreateIfNotExists(); } this.busEvents = new List<IEvent>(); var busMock = new Mock<IEventBus>(); busMock.Setup(b => b.Publish(It.IsAny<Envelope<IEvent>>())).Callback<Envelope<IEvent>>(e => busEvents.Add(e.Body)); busMock.Setup(b => b.Publish(It.IsAny<IEnumerable<Envelope<IEvent>>>())).Callback<IEnumerable<Envelope<IEvent>>>(es => busEvents.AddRange(es.Select(e => e.Body))); this.service = new ConferenceService(busMock.Object, this.dbName); this.conference = new ConferenceInfo { OwnerEmail = "*****@*****.**", OwnerName = "test owner", AccessCode = "qwerty", Name = "test conference", Description = "test conference description", Location = "redmond", Slug = "test", StartDate = DateTime.UtcNow, EndDate = DateTime.UtcNow.Add(TimeSpan.FromDays(2)), IsPublished = true, Seats = { new SeatType { Name = "general", Description = "general description", Price = 100, Quantity = 10, } } }; service.CreateConference(this.conference); }
public ConferenceConfigurationIntegrationSteps() { conferenceService = new ConferenceService(ConferenceHelper.BuildEventBus()); }
public given_an_existing_conference_with_a_seat() { using (var context = new ConferenceContext(dbName)) { if (context.Database.Exists()) context.Database.Delete(); context.Database.CreateIfNotExists(); } this.bus = new MemoryEventBus(); this.service = new ConferenceService(this.bus, this.dbName); this.conference = new ConferenceInfo { OwnerEmail = "*****@*****.**", OwnerName = "test owner", AccessCode = "qwerty", Name = "test conference", Description = "test conference description", Location = "redmond", Slug = "test", StartDate = DateTime.UtcNow, EndDate = DateTime.UtcNow.Add(TimeSpan.FromDays(2)), IsPublished = true, Seats = { new SeatType { Name = "general", Description = "general description", Price = 100, Quantity = 10, } } }; service.CreateConference(this.conference); }
public static Order FindOrder(Guid conferenceId, Guid orderId) { var svc = new ConferenceService(BuildEventBus()); return svc.FindOrders(conferenceId).FirstOrDefault(o => o.Id == orderId); }