public static IDev2TOFn CreateNewDTO(IDev2TOFn dto, int index = 0, bool inserted = false, string initializeWith = "") { IDev2TOFn toReturn = null; TypeSwitch.Do(dto, // ReSharper disable ImplicitlyCapturedClosure TypeSwitch.Case<ActivityDTO>(x => toReturn = new ActivityDTO(initializeWith, "", index, inserted)), // ReSharper restore ImplicitlyCapturedClosure TypeSwitch.Case<DataSplitDTO>(x => { var dataSplitDto = dto as DataSplitDTO; if(dataSplitDto != null) { toReturn = new DataSplitDTO(initializeWith, dataSplitDto.SplitType, dataSplitDto.At, index, false, inserted); } }), TypeSwitch.Case<DataMergeDTO>(x => { var dataMergeDto = dto as DataMergeDTO; if(dataMergeDto != null) { toReturn = new DataMergeDTO(initializeWith, dataMergeDto.MergeType, dataMergeDto.At, index, dataMergeDto.Padding, dataMergeDto.Alignment, inserted); } }), TypeSwitch.Case<CaseConvertTO>(x => { var caseConvertTO = dto as CaseConvertTO; if(caseConvertTO != null) { toReturn = CaseConverterFactory.CreateCaseConverterTO(initializeWith, caseConvertTO.ConvertType, caseConvertTO.Result, index); } }), TypeSwitch.Case<BaseConvertTO>(x => { var baseConvertTO = dto as BaseConvertTO; if(baseConvertTO != null) { toReturn = new BaseConvertTO(initializeWith, baseConvertTO.FromType, baseConvertTO.ToType, baseConvertTO.ToExpression, index, inserted); } }), // ReSharper disable ImplicitlyCapturedClosure TypeSwitch.Case<GatherSystemInformationTO>(x => toReturn = // ReSharper restore ImplicitlyCapturedClosure new GatherSystemInformationTO(enTypeOfSystemInformationToGather.FullDateTime, initializeWith, index, inserted)), // ReSharper disable ImplicitlyCapturedClosure TypeSwitch.Case<XPathDTO>(x => toReturn = new XPathDTO(initializeWith, "", index, inserted)), // ReSharper restore ImplicitlyCapturedClosure // ReSharper disable ImplicitlyCapturedClosure TypeSwitch.Case<FindRecordsTO>(() => toReturn = new FindRecordsTO("", "", index, inserted)), // ReSharper restore ImplicitlyCapturedClosure // ReSharper disable ImplicitlyCapturedClosure TypeSwitch.Default(() => toReturn = null)); // ReSharper restore ImplicitlyCapturedClosure return toReturn; }
public void ActivityDTO_Constructor_Construct_IsInstanceOfTypeIPerformsValidation() { //------------Setup for test-------------------------- const string fieldName = "MyField"; const string fieldValue = "MyFieldValue"; const int indexNumber = 2; const bool inserted = true; //------------Execute Test--------------------------- var activityDTO = new ActivityDTO(fieldName, fieldValue, indexNumber, inserted); //------------Assert Results------------------------- Assert.IsInstanceOfType(activityDTO, typeof(IPerformsValidation)); }
public void ActivityDTO_Constructor_EmptyConstructor_SetsFieldNameFieldValueIndexNumber() { //------------Setup for test-------------------------- //------------Execute Test--------------------------- var activityDTO = new ActivityDTO(); //------------Assert Results------------------------- Assert.AreEqual("[[Variable]]", activityDTO.FieldName); Assert.AreEqual("Expression", activityDTO.FieldValue); Assert.AreEqual(0, activityDTO.IndexNumber); Assert.AreEqual(false, activityDTO.Inserted); Assert.IsNotNull(activityDTO.Errors); }
public void ActivityDTO_Constructor_ConstructorWithParameters_SetsProperties() { //------------Setup for test-------------------------- const string fieldName = "MyField"; const string fieldValue = "MyFieldValue"; const int indexNumber = 2; const bool inserted = true; //------------Execute Test--------------------------- var activityDTO = new ActivityDTO(fieldName, fieldValue, indexNumber, inserted); //------------Assert Results------------------------- Assert.AreEqual(fieldName, activityDTO.FieldName); Assert.AreEqual(fieldValue, activityDTO.FieldValue); Assert.AreEqual(indexNumber, activityDTO.IndexNumber); Assert.AreEqual(inserted, activityDTO.Inserted); Assert.IsNotNull(activityDTO.Errors); }
// ReSharper disable InconsistentNaming public void DataGridFocusTextOnLoadBehavior_OnAssociatedObjectLoaded_TextBoxGetsFocus() // ReSharper restore InconsistentNaming { //init var mockDatagrid = new Mock<DataGrid>(); var mockModelItem = new Mock<ModelItem>(); var mockContext = new Mock<IDev2TOFn>(); var mockTextbox = new Mock<TextBox>(); var behaviour = new Mock<testDataGridFocusTextOnLoadBehavior>(); var dto = new ActivityDTO(); mockContext.Setup(c => c.Inserted).Returns(true); mockModelItem.Setup(c => c.GetCurrentValue()).Returns(mockContext.Object); dto.Inserted = true; mockDatagrid.Object.Items.Add(dto); behaviour.Setup(c => c.GetVisualChild<TextBox>(mockDatagrid.Object)).Returns(mockTextbox.Object); behaviour.Setup(c => c.GetVisualChild<TextBox>(mockDatagrid.Object)).Verifiable(); //exe behaviour.Object.TestAssociatedObject_Loaded(mockDatagrid); //assert behaviour.Verify(c => c.GetVisualChild<TextBox>(mockDatagrid.Object), Times.Once()); }
public void ActivityDTO_FieldName_ValidatesForErrors_ReturnsError() { //------------Setup for test-------------------------- var activityDTO = new ActivityDTO(); activityDTO.FieldName = "1"; //------------Execute Test--------------------------- activityDTO.Validate(() => activityDTO.FieldName, ""); //------------Assert Results------------------------- Assert.AreEqual(1, activityDTO.Errors.Count); }
public void ActivityDTO_Validate_GivenRules_HasPassingRuleReturnTrue() { //------------Setup for test-------------------------- var activityDTO = new ActivityDTO { FieldName = "FeildName" }; var ruleSet = new RuleSet(); ruleSet.Add(new IsNullRule(() => activityDTO.FieldName)); //------------Execute Test--------------------------- bool isValid = activityDTO.Validate("FieldName", ruleSet); //------------Assert Results------------------------- Assert.IsTrue(isValid); }
public void ActivityDTO_GetRuleSet_OnFieldValue_ReturnTwoRules() { //------------Setup for test-------------------------- var activityDto = new ActivityDTO { FieldName = "[[a]]", FieldValue = "[[b]]" }; //------------Execute Test--------------------------- var rulesSet = activityDto.GetRuleSet("FieldValue", ""); //------------Assert Results------------------------- Assert.IsNotNull(rulesSet); Assert.AreEqual(1, rulesSet.Rules.Count); Assert.IsInstanceOfType(rulesSet.Rules[0], typeof(IsValidExpressionRule)); }
public void ActivityDTO_OutList_Property_ListOfString() { //------------Setup for test-------------------------- var activityDTO = new ActivityDTO(); var expectedOutList = new List<string> { "TestValue" }; activityDTO.OutList = expectedOutList; //------------Execute Test--------------------------- var outList = activityDTO.OutList; //------------Assert Results------------------------- CollectionAssert.AreEqual(expectedOutList, outList); }
public void ActivityDTO_Validate_GivenNoRules_ReturnTrue() { //------------Setup for test-------------------------- var activityDTO = new ActivityDTO(); //------------Execute Test--------------------------- bool isValid = activityDTO.Validate("FieldName", new RuleSet()); //------------Assert Results------------------------- Assert.IsTrue(isValid); }
public ActionResult Result(string asks, long id = 0) { ActivityDTO activity = new ActivityDTO(); if (id == 0) { return(Redirect("/home/index")); } if (!activityService.ExistActivity(id)) { return(Redirect("/home/index")); } else if (!activityService.IsCurrentAct(id)) { return(Redirect("/home/index")); } else { activity = activityService.GetById(id); } if (activity.StatusId == 5 || activity.StatusId == 7 || activity.StatusId == 8) { return(Redirect("/home/index")); } if (Session["IsFirst"] == null) { return(Redirect("/home/index")); } if ((bool)Session["IsFirst"]) { if (string.IsNullOrEmpty(asks)) { return(Content("请答完题再提交")); } ResultModel model = new ResultModel(); model.ActivityName = activity.Name; model.Id = activity.Id; model.PrizeTime = activity.RewardTime.ToString("yyyy-MM-dd HH:mm"); long paperId = activity.PaperId; string[] strs = asks.Trim(',').Split(','); List <string> lists = new List <string>(); int count = 0; foreach (string str in strs) { string[] results = str.Split(':'); bool b = exeService.IsRightOrWrong(paperId, Convert.ToInt64(results[0]), Convert.ToInt64(results[1])); if (b) { count++; } lists.Add(b ? "right" : "wrong"); } model.IsAllRight = count == strs.Count(); model.Result = lists; model.IsFirst = true; return(View(model)); } else { if (string.IsNullOrEmpty(asks)) { return(Content("请答完题再提交")); } ResultModel model = new ResultModel(); model.ActivityName = activity.Name; model.Id = activity.Id; model.PrizeTime = activity.RewardTime.ToString("yyyy-MM-dd HH:mm"); long paperId = activity.PaperId; string[] strs = asks.Trim(',').Split(','); List <string> lists = new List <string>(); int count = 0; foreach (string str in strs) { string[] results = str.Split(':'); bool b = exeService.IsRightOrWrong(paperId, Convert.ToInt64(results[0]), Convert.ToInt64(results[1])); if (b) { count++; } lists.Add(b ? "right" : "wrong"); } model.IsAllRight = count == strs.Count(); model.Result = lists; model.IsFirst = false; return(View(model)); } }
public async Task <ActivityDTO> SaveActivity(ActivityDTO activity) { return(await _baseHubITest.HttpPostAsync <ActivityDTO, ActivityDTO>(_baseHubITest.GetHubApiBaseUrl() + "activities/save", activity)); }
public static ActivityResponseDTO AddActivityDTO(this ActivityResponseDTO activityResponse, ActivityDTO activityDTO) { return(AddBaseDTO <ActivityDTO>(activityResponse, ActivityPropertyName, activityDTO)); }
public static bool TryParseActivityDTO(this ActivityResponseDTO activityResponse, out ActivityDTO activityDTO) { return(TryParseBaseDTO <ActivityDTO>(activityResponse, ActivityPropertyName, out activityDTO)); }
private void AssertActivityDTO(Activity activity, ActivityDTO dto) { AssertDTO(activity, dto, new[] { "ActivityID", "Name", "DayOfWeek", "PreferredTime" }); AssertLocationDTO(activity.Location, new LocationDTO(activity.Location)); }
public TestActivityDTO(ActivityDTO activityDto) { _act = activityDto; IndexNumber = activityDto.IndexNumber; }
public TestActivityDTO(ActivityDTO activityDto) { _act = activityDto; IndexNumber = activityDto.IndexNumber; }
protected ActivityBaseViewModel(ActivityDTO model) { _model = model; }
public ActivityDTO SaveActivity(Token token, ActivityDTO activity) { return(exceptionHandling(token, () => InternalService.SaveActivity(token, activity))); }
public void DeleteActivity(Token token, ActivityDTO activity) { exceptionHandling(token, () => InternalService.DeleteActivity(token, activity)); }
public async Task <IHttpActionResult> PutActivity(int id, ActivityDTO activityDTO) { var automapperConfig = new AutoMapperConfig().Configure(); string userId = User.Identity.GetUserId(); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var category = db.Categories.SingleOrDefault(q => q.UserId == userId && q.Name == activityDTO.CategoryName && q.IsDeleted == false); if (category == null) { return(BadRequest("Category not valid.")); } if (id != activityDTO.Id) { return(BadRequest()); } var activity = await db.Activities.AsNoTracking().FirstOrDefaultAsync(q => q.Id == id && q.IsDeleted == false); if (activity == null) { return(NotFound()); } if (userId != activity.UserId) { return(BadRequest("No right access to update")); } var updatedActivity = automapperConfig.CreateMapper().Map <ActivityDTO, Activity>(activityDTO); activity = db.Activities.Attach(updatedActivity); db.Entry(activity).State = EntityState.Modified; try { db.UserId = userId; await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ActivityExists(id)) { return(NotFound()); } else { return(BadRequest("The model is invalid")); } } return(Ok()); }
public static bool IsStorageEmpty(this ICrateManager crateManager, ActivityDTO activity) { return(crateManager.IsEmptyStorage(activity.CrateStorage)); }
/// <summary> /// Prepare AuthToken for ActionDTO request message. /// </summary> public void PrepareAuthToken(IUnitOfWork uow, ActivityDTO activityDTO) { // Fetch Action. var activity = uow.PlanRepository.GetById <ActivityDO>(activityDTO.Id); if (activity == null) { throw new ApplicationException("Could not find Action."); } if (activity.ActivityTemplateId == null) { throw new ApplicationException("Activity without a template should not exist"); } var activityTemplate = _activityTemplate.GetByKey(activity.ActivityTemplateId); // Try to find AuthToken if terminal requires authentication. if (activityTemplate.NeedsAuthentication && activityTemplate.Terminal.AuthenticationType != AuthenticationType.None) { AuthorizationTokenDO authToken; TryAssignAuthToken(uow, activity.Fr8AccountId, activityTemplate.TerminalId, activity, out authToken); // If AuthToken is not empty, fill AuthToken property for ActionDTO. if (authToken != null && !string.IsNullOrEmpty(authToken.Token)) { activityDTO.AuthToken = new AuthorizationTokenDTO { Id = authToken.Id.ToString(), ExternalAccountId = authToken.ExternalAccountId, ExternalAccountName = string.IsNullOrEmpty(authToken.ExternalAccountName) ? authToken.ExternalAccountId : authToken.ExternalAccountName, ExternalDomainId = authToken.ExternalDomainId, ExternalDomainName = string.IsNullOrEmpty(authToken.ExternalDomainName) ? authToken.ExternalDomainId : authToken.ExternalDomainName, UserId = authToken.UserID, Token = authToken.Token, ExpiresAt = authToken.ExpiresAt, AdditionalAttributes = authToken.AdditionalAttributes }; } else { throw new InvalidTokenRuntimeException(activityDTO); } if (String.IsNullOrEmpty(authToken.Token)) { throw new InvalidTokenRuntimeException(activityDTO); } } if (activityDTO.AuthToken == null) { if (activity.Fr8AccountId != null) { activityDTO.AuthToken = new AuthorizationTokenDTO { UserId = activity.Fr8AccountId, }; } } }
public ActivityDTO Create(ActivityDTO dto) { return(base.Create <ActivityDTO, Activity>(dto , _IActivityRepository , dtoAction => { })); }
public async Task <IEnumerable <PersonOrganizedActivity> > OrganizersDtoListToOrganizerList(ActivityDTO value, int Id) { var Organizers = new List <PersonOrganizedActivity>(); foreach (var personOrganizer in value.Organizers) { personOrganizer.ActivityId = Id; if (await organizedContext.GetOrganizedActivitiesByPersonIdAndActivityId(personOrganizer.PersonId, personOrganizer.ActivityId) != null) { var OrganizerToUpdate = (PersonOrganizedActivity)personOrganizer; await organizedContext.UpdateOrganizedActivities(OrganizerToUpdate); } else { var OrganizerToAdd = (PersonOrganizedActivity)personOrganizer; context.PersonOrginizers.Add(OrganizerToAdd); } Organizers.Add((PersonOrganizedActivity)personOrganizer); } return(Organizers); }
public void ActivityDTO_ConvertToOutputTO_Executed_ReturnsOutputTO() { //------------Setup for test-------------------------- var activityDTO = new ActivityDTO(); //------------Execute Test--------------------------- var convertToOutputTO = activityDTO.ConvertToOutputTO(); //------------Assert Results------------------------- Assert.IsNotNull(convertToOutputTO); }
public async Task <IEnumerable <PersonInvites> > PersonInviteDtoListToPersonInviteList(ActivityDTO value, int Id) { var InvitedPeople = new List <PersonInvites>(); foreach (var personInvite in value.InvitedGuests) { personInvite.ActivityId = Id; if (await inviteContext.GetInviteByPersonIdAndActivityId(personInvite.PersonId, personInvite.ActivityId) != null) { var InviteToUpdate = (PersonInvites)personInvite; await inviteContext.UpdateInvite(InviteToUpdate); } else { var invite = (PersonInvites)personInvite; context.PersonActivities.Add(invite); } InvitedPeople.Add((PersonInvites)personInvite); } return(InvitedPeople); }
public void ActivityDTO_ValidateRules_NullRuleSet_ReturnsTrue() { //------------Setup for test-------------------------- var activityDTO = new ActivityDTO(); //------------Execute Test--------------------------- var validate = activityDTO.Validate("FieldName", (IRuleSet)null); //------------Assert Results------------------------- Assert.IsTrue(validate); }
private void replace(ActivityDTO selected, ActivityDTO saved) { ActivitiesReposidory.Instance.Replace(selected, saved); SelectedActivity = saved; NotifyOfPropertyChange(() => Activities); }
public async Task <ActivityDTO> ConfigureActivity(ActivityDTO activity) { activity = await _baseHubITest.HttpPostAsync <ActivityDTO, ActivityDTO>(_baseHubITest.GetHubApiBaseUrl() + "activities/configure", activity); return(activity); }
/// <summary> /// After receiving response from terminals for activate action call, checks for existing validation errors on some controls /// </summary> /// <param name="curActivityDTO"></param> /// <param name="containerDTO">Use containerDTO as a wrapper for the Error with proper ActivityResponse and error DTO</param> /// <returns></returns> public IEnumerable <ValidationResultDTO> ExtractValidationErrors(ActivityDTO curActivityDTO) { var crateStorage = _crate.GetStorage(curActivityDTO); return(crateStorage.CrateContentsOfType <ValidationResultsCM>().SelectMany(x => x.ValidationErrors)); }
public void ActivityDTO_Validate_Executed_SetErrorsProperty() { //------------Setup for test-------------------------- var activityDTO = new ActivityDTO { FieldName = null }; var ruleSet = new RuleSet(); ruleSet.Add(new IsNullRule(() => activityDTO.FieldName)); //------------Execute Test--------------------------- activityDTO.Validate("FieldName", ruleSet); //------------Assert Results------------------------- Assert.AreEqual(1, activityDTO.Errors.Count); }
public InvalidTokenRuntimeException(ActivityDTO activityDTO) : base(null, null) { FailedActivityDTO = activityDTO; }
public void ActivityDTO_OnPropertyChanged_ErrorsChanged_FiresPropertyChanged() { //------------Setup for test-------------------------- var activityDTO = new ActivityDTO(); var value = new Dictionary<string, List<IActionableErrorInfo>>(); //------------Execute Test--------------------------- var propertyChangedFired = TestUtils.PropertyChangedTester(activityDTO, () => activityDTO.Errors, () => activityDTO.Errors = value); //------------Assert Results------------------------- Assert.IsTrue(propertyChangedFired); }
public static IUpdatableCrateStorage GetUpdatableStorage(this ICrateManager crateManager, ActivityDTO activity) { if (activity == null) { throw new ArgumentNullException(nameof(activity)); } return(crateManager.UpdateStorage(() => activity.CrateStorage)); }
public IHttpActionResult Process(ActivityDTO curActivityDTO) { return (Ok("This end point has been deprecated. Please use the V2 mechanisms to POST to this terminal. For more" + "info see https://maginot.atlassian.net/wiki/display/SH/V2+Plugin+Design")); }
public ActivityViewModel Save(ActivityDTO activityDTO) { Activity savedActivity = activityRepository.Save(BuildModel(activityDTO)); return(BuildViewModel(savedActivity)); }
public void ActivityDTO_OnPropertyChanged_FieldValueChanged_FiresPropertyChanged() { //------------Setup for test-------------------------- var activityDTO = new ActivityDTO(); const string value = "value"; //------------Execute Test--------------------------- var propertyChangedFired = TestUtils.PropertyChangedTester(activityDTO, () => activityDTO.FieldValue, () => activityDTO.FieldValue = value); //------------Assert Results------------------------- Assert.IsTrue(propertyChangedFired); }
private void _handlerRelatoriosCMBox() { setCMBoxValues(StudentsDTO.getAllStudentsName(), cmbNomeAluno); setCMBoxValues(InstructorDTO.getAllInstructorsName(), cmbNomeMonitor); setCMBoxValues(ActivityDTO.getAllActivitiesTitle(), cmbActivities); }
public InvalidTokenRuntimeException(ActivityDTO activityDTO, string message) : base(message, null) { FailedActivityDTO = activityDTO; }
//dobija se aktivnost sa definisanim input i output dok public void SaveActivity(ActivityDTO dto) { Activity = Mapper.Map <Activity>(dto); _bus.Start(Activity); }
public InvalidTokenRuntimeException(ActivityDTO activityDTO, ContainerDTO containerDTO, string message) : base(activityDTO, containerDTO, message) { }
public void ActivityDTO_OnPropertyChanged_IndexNumberChanged_FiresPropertyChanged() { //------------Setup for test-------------------------- var activityDTO = new ActivityDTO(); const int value = 2; //------------Execute Test--------------------------- var propertyChangedFired = TestUtils.PropertyChangedTester(activityDTO, () => activityDTO.IndexNumber, () => activityDTO.IndexNumber = value); //------------Assert Results------------------------- Assert.IsTrue(propertyChangedFired); }
public static ICrateStorage GetStorage(this ICrateManager crateManager, ActivityDTO activity) { return(crateManager.FromDto(activity.CrateStorage)); }
public void ActivityDTO_CanRemove_FieldNameHasValueAndFieldValueNull_False() { //------------Setup for test-------------------------- var activityDTO = new ActivityDTO { FieldName = "FieldName", FieldValue = null }; //------------Execute Test--------------------------- var canRemove = activityDTO.CanRemove(); //------------Assert Results------------------------- Assert.IsFalse(canRemove); }
private static string EditActivityURL(ActivityDTO activity) { return($"<a href =\"/Settings/EditActivity/{activity.ActivityId}\">{activity.Name}</a>"); }
public void ActivityDTO_CanAdd_FieldNameAndFieldValueEmpty_False() { //------------Setup for test-------------------------- var activityDTO = new ActivityDTO { FieldName = "", FieldValue = "" }; //------------Execute Test--------------------------- var canRemove = activityDTO.CanAdd(); //------------Assert Results------------------------- Assert.IsFalse(canRemove); }
public async Task <bool> SaveActivity(ActivityDTO item, CancellationToken token) { _items.Add(item); return(await Task.FromResult(true)); }
public void ActivityDTO_CanAdd_FieldNameNullAndFieldValueHasValue_True() { //------------Setup for test-------------------------- var activityDTO = new ActivityDTO { FieldName = null, FieldValue = "FieldValue" }; //------------Execute Test--------------------------- var canRemove = activityDTO.CanAdd(); //------------Assert Results------------------------- Assert.IsTrue(canRemove); }
public void ActivityDTO_ClearRow_Executed_SetsFieldNameFieldValueToEmptyString() { //------------Setup for test-------------------------- var activityDTO = new ActivityDTO(); //------------Precondition---------------------------- Assert.IsFalse(string.IsNullOrEmpty(activityDTO.FieldName)); Assert.IsFalse(string.IsNullOrEmpty(activityDTO.FieldValue)); //------------Execute Test--------------------------- activityDTO.ClearRow(); //------------Assert Results------------------------- Assert.AreEqual(string.Empty, activityDTO.FieldName); Assert.AreEqual(string.Empty, activityDTO.FieldValue); }
private static Fr8DataDTO ConvertToFr8Data(ActivityDTO activityDTO) { return(new Fr8DataDTO { ActivityDTO = activityDTO }); }