public void TestRetrieveEventTags() { // Arrange List <string> expected = new List <string> { "Indoors", "Food" }; List <string> actual; const bool desiredResult = true; var result = false; EventTagService eventTagService = new EventTagService(); EventService eventService = new EventService(); UserService userService = new UserService(); // Act // Creates temp user var firstName = "Example"; var lastName = "Set"; var userName = "******"; var city = "Long Beach"; var state = "California"; var country = "United States"; var dob = DateTime.Parse("09/19/1999"); var user = new User(UserId1, firstName, lastName, userName, city, state, country, dob, true); userService.InsertUser(user); // Creates temp event var eventTime = DateTime.Parse("5/20/2028"); var eventName = "TestIn Party"; var place = "CSULB"; var newEvent = new Event(UserId1, EventId1, eventTime, eventName, place, ""); eventService.InsertMadeEvent(newEvent); var foundEvent = eventService.GetEventById(EventId1); // Adds event Tags to event eventTagService.InsertEventTag(EventId1, TId1); eventTagService.InsertEventTag(EventId1, TId2); // Test actual = eventTagService.ReturnEventTagsOfEvent(EventId1); if (!expected.Except(actual).Any()) { result = true; } // Cleanup userService.DeleteUser(user); eventTagService.DeleteEventTag(EventId1, TId1); eventTagService.DeleteEventTag(EventId1, TId2); if (foundEvent != null) { eventService.DeleteEvent(EventId1, UserId1, ""); } // Assert Assert.AreEqual(desiredResult, result); }
public EventsController(EventTypeService eventTypeService, EventCategoryService eventCategoryService, CountryService countryService, TagService tagService, EventService eventService, EventTagService eventTagService) { this.eventTypeService = eventTypeService; this.eventCategoryService = eventCategoryService; this.countryService = countryService; this.tagService = tagService; this.eventService = eventService; this.eventTagService = eventTagService; }
public void PassTestSortByTagsAndDateRange() { // Arrange var eventFinderService = new EventFinderService(); var userService = new UserService(); var eventService = new EventService(); var eventTagService = new EventTagService(); const bool expected = true; var result = false; // Act var dob = DateTime.Parse("09/19/1999"); var user = new User(UserId1, FirstName, LastName, UserName, City, State, Country, dob, true); userService.InsertUser(user); var eventTime = DateTime.Parse("5/25/2028"); var expectedEvent = new Event(UserId1, EventId1, eventTime, EventName, Place, ""); eventService.InsertMadeEvent(expectedEvent); var eventTime2 = DateTime.Parse("5/20/2028"); var expectedEvent2 = new Event(UserId1, EventId2, eventTime2, EventName2, Place, ""); eventService.InsertMadeEvent(expectedEvent2); // TagId 4 -> Art eventTagService.InsertEventTag(EventId1, "Art"); eventTagService.InsertEventTag(EventId2, "Art"); var foundEvents = eventFinderService.FindEventByEventTags(new List <string>() { "Art" }); var sortedEvents = eventFinderService.CullEventListByDateRange(foundEvents, "5/20/2028", "5/25/2028"); if (sortedEvents[0].EventId == expectedEvent2.EventId && sortedEvents[1].EventId == expectedEvent.EventId) { result = true; } // Cleanup userService.DeleteUser(user); eventTagService.DeleteEventTag(EventId1, "Art"); eventTagService.DeleteEventTag(EventId2, "Art"); eventService.DeleteEvent(EventId1, UserId1, ""); eventService.DeleteEvent(EventId2, UserId1, ""); // Assert Assert.AreEqual(expected, result); }
private async void OnDelete() { var messageBoxResult = MessageBox.Show("Are you sure you want to delete this item?", AppName, MessageBoxButton.YesNo); if (messageBoxResult == MessageBoxResult.No) { return; } var eventTagService = new EventTagService(); var result = await eventTagService.DeleteEventTag(SelectedEvent); MessageBox.Show(result, AppName, MessageBoxButton.OK, MessageBoxImage.Information); GetEventTags(); }
public void PassTestFindEventsByTag() { // Arrange var eventFinderService = new EventFinderService(); var userService = new UserService(); var eventService = new EventService(); var eventTagService = new EventTagService(); const bool expected = true; var result = false; // Act var dob = DateTime.Parse("09/19/1999"); var user = new User(UserId1, FirstName, LastName, UserName, City, State, Country, dob, true); userService.InsertUser(user); var eventTime = DateTime.Parse("5/20/2028"); var expectedEvent = new Event(UserId1, EventId1, eventTime, EventName, Place, ""); eventService.InsertMadeEvent(expectedEvent); // TagId 4 -> Art eventTagService.InsertEventTag(EventId1, "Art"); var foundEvents = eventFinderService.FindEventByEventTags(new List <string>() { "Art" }); foreach (var events in foundEvents) { if (events.EventId.Equals(expectedEvent.EventId)) { result = true; } } // Cleanup userService.DeleteUser(user); eventTagService.DeleteEventTag(EventId1, "Art"); eventService.DeleteEvent(EventId1, UserId1, ""); // Assert Assert.AreEqual(expected, result); }
private async void OnUpload() { string headerFileName = Path.Combine(FileEndPointManager.Project2Folder, "header.json"); using (StreamWriter file = File.CreateText(headerFileName)) { JsonSerializer serializer = new JsonSerializer(); serializer.Serialize(file, EventToAdd); } string recordJSDirectory = FileEndPointManager.DefaultPlayXMLFile; string recordXMLDirectory = FileEndPointManager.DefaultLatestXMLFile; if (!File.Exists(recordJSDirectory) || !File.Exists(recordXMLDirectory)) { //TODO: update this error message. MessageBox.Show("There are no record files to save. Please open an existing recording or make a new one.", AppName, MessageBoxButton.OK, MessageBoxImage.Error); } else { List <string> fullPathsOfFilesToCompress = new List <string> { recordJSDirectory, recordXMLDirectory, headerFileName }; string eventToUploadFileName = Path.Combine(FileEndPointManager.Project2Folder, EventToAdd.FileName + "." + RecordFileExtension); ZipArchiveHelper.ArchiveFiles(fullPathsOfFilesToCompress, eventToUploadFileName); EventTagService eventTagService = new EventTagService(); _progressBar = new ProgressBarSharedView("Uploading file. Please wait..."); _progressBar.Show(); var result = await eventTagService.CreateEvent(eventToUploadFileName); _progressBar.Close(); MessageBox.Show(result, AppName, MessageBoxButton.OK, MessageBoxImage.Information); File.Delete(eventToUploadFileName); } }
public EventTagViewModel(MainWindow mainWindow = null) { _eventTagService = new EventTagService(); _eventParameterService = new EventParameterService(); _mainWindow = mainWindow; UpdateCommand = new RelayCommand(OnUpdate, CanUpdate); DeleteCommand = new RelayCommand(OnDelete, CanDelete); RefreshCommand = new RelayCommand(OnRefresh); UpdateParameterCommand = new RelayCommand(OnUpdateParameter, CanUpdateParameter); DeleteParameterCommand = new RelayCommand(OnDeleteParameter, CanDeleteParameter); CreateParameterCommand = new RelayCommand(OnCreateParameter, CanCreateParameter); CommitCreateCommand = new RelayCommand(OnCommitCreateParameter); CancelCreateCommand = new RelayCommand(OnCancelCreateParameter); RefreshParametersCommand = new RelayCommand(OnRefreshParameters, CanRefreshParameters); PlayScriptCommand = new RelayCommand(OnPlayScript, CanPlayScript); CreatingItem = false; ConfigManager configManager = new ConfigManager(); TenantId = configManager.GetValue("TenantId"); AppName = configManager.GetValue("AppName"); }