public void ConvertHandlesSubtraction() { var parameter = new DateParameter(); var actualValue = parameter.Convert("Today-2"); Assert.AreEqual(DateTime.Today.AddDays(-2), actualValue); }
public void ConstructorSetsName() { var name = "newParam"; var parameter = new DateParameter(name); Assert.AreEqual(name, parameter.Name); }
/// <summary> /// This will take the dateParameters and return a list of all the GroupDataTypes with the year data /// </summary> /// <param name="list"></param> /// <param name="minDate"></param> /// <param name="maxDate"></param> /// <returns></returns> public DashBoardSingle GetFinalData(DateParameter dateParam, DateTime dateOfTrx, string showDataBelongingTo, string groupBy, string name) { //DashBoardSingle dbs = new DashBoardSingle(); PageViewData pvd = new PageViewData(); pvd.Heading = dateParam.Heading; //this gets the data filtered by the date List <PageView> lstWithinDate = filterForBeginEndDate(dateParam); lstWithinDate = fix_RawData(dateOfTrx, groupBy, name, lstWithinDate); //string dataType = GroupByConstants.MAIN; //now insert all the data in pvd.AllData var dbs = pvd.InitializePageViews(lstWithinDate, dateParam, groupBy, showDataBelongingTo); long noOfPageViews = lstWithinDate.Count(); //if name has been passed... trim the overall data noOfPageViews = trimDataForNameAndBelongingTo(showDataBelongingTo, name, dbs, noOfPageViews); var dbsFixed = pvd.Controller_FixKey(dbs, groupBy); var dbsGrouped = pvd.Controller_SQL(dbsFixed, groupBy); var dbsGroupedFixed = pvd.FixDateInGroupAndChild(dbsGrouped, groupBy); dbs.Amount = noOfPageViews; dbs.TotalAmount = noOfPageViews; return(dbsGroupedFixed); }
public void AddDefaultValuesToDelivrymanOfferVariables(BuySellDoc buySellDoc) { DateParameter dp = new DateParameter(); dp.BeginDate = buySellDoc.PleasePickupOnDate_Start; dp.EndDate = buySellDoc.PleasePickupOnDate_End; if (IsWithinDate(buySellDoc)) { if (buySellDoc.OfferedPickupOnDate == DateTime.MinValue || buySellDoc.OfferedPickupOnDate == DateTime.MaxValue) { buySellDoc.OfferedPickupOnDate = DateTime.Now; } if (buySellDoc.FreightOffer.IsNullOrWhiteSpace()) { buySellDoc.FreightOffer = buySellDoc.FreightCustomerBudget_String; } else { if (buySellDoc.FreightOfferDecimal == 0) { buySellDoc.FreightOffer = buySellDoc.FreightCustomerBudget_String; } } } }
public void ConvertHandlesDayOfWeek() { var parameter = new DateParameter(); var actualValue = parameter.Convert("dayofweek(3)"); Assert.AreEqual(DateTime.Today.AddDays(-(int)DateTime.Today.DayOfWeek + 3), actualValue); }
public void ConvertHandlesDayOfMonth() { var parameter = new DateParameter(); var actualValue = parameter.Convert("dayofmonth(10)"); Assert.AreEqual(DateTime.Today.AddDays(-DateTime.Today.Day + 10), actualValue); }
private void addRecord( string name, DateTime dateCreated, bool isCrawler, DateParameter dateParam, string groupBy, string showDataFor, string belongsToGroup) { //if (groupBy.IsNullOrWhiteSpace()) // groupBy = DashBoardConstants.YEAR; string _userName = string.Format("{0}", name); DashBoardSingle ds = new DashBoardSingle( _userName, dateCreated, isCrawler, showDataFor, 0, dateParam.BeginDate, dateParam.EndDate, groupBy, showDataFor, belongsToGroup); DataAll.DataDetail.Add(ds); }
public void ConvertHandlesEmptyString() { var parameter = new DateParameter(); var actualValue = parameter.Convert(string.Empty); Assert.AreEqual(DateTime.Today, actualValue); }
public void ConvertHandlesDate() { var parameter = new DateParameter(); var actualValue = parameter.Convert("2010-01-01"); Assert.AreEqual(new DateTime(2010, 1, 1), actualValue); }
public string ExpiryDateInNoOfDays(DateTime expiryDate) { string expiryDateInNoOfDays = new DateParameter().ToNoOfDaysAway(expiryDate); string str = string.Format("{0} ({1:N0})", expiryDate.ToLongDateString(), expiryDateInNoOfDays); return(str); }
public void ConvertHandlesToday() { var parameter = new DateParameter(); var actualValue = parameter.Convert("Today"); Assert.AreEqual(DateTime.Today, actualValue); }
public void ValidateChecksThatTheValueIsADate() { var parameter = new DateParameter("Test"); var exceptions = parameter.Validate("notadate!"); Assert.AreEqual(1, exceptions.Length); Assert.AreEqual("Value of 'Test' is not a date", exceptions[0].Message); }
public void CanGenerateDefault() { var parameter = new DateParameter(); parameter.ClientDefaultValue = "today"; parameter.GenerateClientDefault(); Assert.AreEqual(DateTime.Today.ToShortDateString(), parameter.ClientDefaultValue); }
public async Task SetsTheDateAccordingToTheDateParameterReceived() { var date = DateTimeOffset.UtcNow; var parameter = DateParameter.WithDate(date); await ViewModel.Initialize(parameter); ViewModel.StartDate.Should().BeSameDateAs(date); }
public void ConvertFailsWhenOperationIsUnknown() { var parameter = new DateParameter(); var error = Assert.Throws <InvalidOperationException>(() => { parameter.Convert("Today*2"); }); Assert.AreEqual("Unknown operation: '*'", error.Message); }
public void ValidateChecksTheDateIsMoreThanMinimum() { var parameter = new DateParameter("Test"); parameter.MinimumValue = new DateTime(2010, 1, 31); var exceptions = parameter.Validate("2010-1-1"); Assert.AreEqual(1, exceptions.Length); Assert.AreEqual("Value of 'Test' is less than the minimum allowed (01/31/2010)", exceptions[0].Message); }
public DashBoardSingle AjaxData(DateTime beginDate, DateTime endDate, DateTime dateOfTrx, string showDataBelongingTo, string groupBy, string name) { DateParameter dateParam = new DateParameter(); dateParam.BeginDate = beginDate; dateParam.EndDate = endDate; DashBoardSingle dbs = GetFinalData(dateParam, dateOfTrx, showDataBelongingTo, groupBy, name); return(dbs); }
public void IsRequiredWithBlank() { var parameter = new DateParameter(); parameter.Name = "Test"; parameter.IsRequired = true; var results = parameter.Validate(string.Empty); Assert.AreEqual(1, results.Length, "Number of exceptions does not match"); Assert.AreEqual("Value of 'Test' is required", results[0].Message, "Exception message does not match"); }
public bool IsWithinDate(BuySellDoc buySellDoc) { DateParameter dp = new DateParameter(); dp.BeginDate = buySellDoc.PleasePickupOnDate_Start; dp.EndDate = buySellDoc.PleasePickupOnDate_End; if (dp.IsDateWithinBeginAndEndDatesInclusive(DateTime.Now)) { return(true); } return(false); }
private void addUserLanguages( string userLanguages, DateTime dateCreated, bool isCrawler, DateParameter dateParam, string groupBy) { if (userLanguages.IsNullOrWhiteSpace()) { return; } if (groupBy.IsNullOrWhiteSpace()) { return; } var _languages = userLanguages.Concat_NowSplitStringWithSeperator(";"); if (_languages.IsNullOrEmpty()) { return; } foreach (var item in _languages) { if (item.IsNullOrWhiteSpace()) { continue; } string itemSpacesRemovedAndUpperCased = item.RemoveAllSpaces().ToUpper(); if (itemSpacesRemovedAndUpperCased.IsNullOrWhiteSpace()) { continue; } addRecord( itemSpacesRemovedAndUpperCased, dateCreated, isCrawler, dateParam, groupBy, DataOwner.USER_HOST_NAMES, DataOwner.USER_HOST_NAMES); } }
private void addUserAgent(string userAgent, DateTime dateCreated, bool isCrawler, DateParameter dateParam, string groupBy) { addRecord( userAgent, dateCreated, isCrawler, dateParam, groupBy, DataOwner.USER_AGENT, DataOwner.USER_AGENT); }
private void addBrowserType( string browserType, DateTime dateCreated, bool isCrawler, DateParameter dateParam, string groupBy) { addRecord( browserType, dateCreated, isCrawler, dateParam, groupBy, DataOwner.BROWSER, DataOwner.BROWSER); }
private void addUserHostAddress( string userHostAddress, DateTime dateCreated, bool isCrawler, DateParameter dateParam, string groupBy) { addRecord( userHostAddress, dateCreated, isCrawler, dateParam, groupBy, DataOwner.USER_HOST_ADDRESS, DataOwner.USER_HOST_ADDRESS); }
private void addUrlReferHost( string urlRefererHost, DateTime dateCreated, bool isCrawler, DateParameter dateParam, string groupBy) { addRecord( urlRefererHost, dateCreated, isCrawler, dateParam, groupBy, DataOwner.REFERAL_HOST, DataOwner.REFERAL_HOST); }
private void addUserHostName( string userHostName, DateTime dateCreated, bool isCrawler, DateParameter dateParam, string groupBy) { addRecord( userHostName, dateCreated, isCrawler, dateParam, groupBy, DataOwner.USER_HOST_NAMES, DataOwner.USER_HOST_NAMES); }
private void addControllerActions( string controller, string action, DateTime dateCreated, bool isCrawler, DateParameter dateParam, string groupBy) { addRecord( controller, dateCreated, isCrawler, dateParam, groupBy, DataOwner.CONTROLLER, DataOwner.CONTROLLER); }
public async Task StartsANewTimeEntry() { var date = DateTimeOffset.UtcNow; var description = "Testing Toggl apps"; var dateParameter = DateParameter.WithDate(date); await ViewModel.Initialize(dateParameter); ViewModel.RawTimeEntryText = description; ViewModel.DoneCommand.Execute(); await DataSource.TimeEntries.Received().Start( Arg.Is(dateParameter.GetDate()), Arg.Is(description), Arg.Is(false) ); }
private void fixDate(BuySellDoc buySellDoc) { DateParameter dt = new DateParameter(); dt.BeginDate = buySellDoc.PleasePickupOnDate_Start; dt.EndDate = buySellDoc.PleasePickupOnDate_End; if (dt.BeginDateAfterEndDate) { DateTime temp = buySellDoc.PleasePickupOnDate_Start; buySellDoc.PleasePickupOnDate_Start = buySellDoc.PleasePickupOnDate_End; buySellDoc.PleasePickupOnDate_End = temp; } if (dt.EndDate == DateTime.MinValue) { dt.EndDate = DateTime.MaxValue; } }
private string not_Within_Shipping_Date_Exception_Or_Message_String(BuySellDoc buySellDoc) { string err = "Error. Document is not known"; if (!IsWithinDate(buySellDoc)) { DateParameter dp = new DateParameter(); dp.BeginDate = buySellDoc.PleasePickupOnDate_Start; dp.EndDate = buySellDoc.PleasePickupOnDate_End; string beginDate = dp.BeginDate.ToShortDateString(); string endDate = dp.EndDate.ToShortDateString(); string todaysDate = DateTime.Now.ToShortDateString(); string customerPhoneNumber = getCustomerPhoneNumber(buySellDoc); string customerName = buySellDoc.Customer.FullName(); switch (buySellDoc.BuySellDocumentTypeEnum) { case BuySellDocumentTypeENUM.Unknown: break; case BuySellDocumentTypeENUM.Purchase: err = string.Format("The shipping window was between {0} and {1}. Today is {2} which is not within the window. {3}, please amend the shipping dates.", beginDate, endDate, todaysDate, customerName); break; case BuySellDocumentTypeENUM.Sale: case BuySellDocumentTypeENUM.Delivery: default: err = string.Format("The shipping window was between {0} and {1}. Today is {2} which is not within the window. Customer to amend the shipping dates. Customer phone number is {3}", beginDate, endDate, todaysDate, customerPhoneNumber); break; } } return(err); }
private void addIsCrawler( bool isCrawler, DateTime dateCreated, string userAgent, DateParameter dateParam, string groupBy) { if (!isCrawler) { return; } addRecord( isCrawler.ToString(), dateCreated, isCrawler, dateParam, groupBy, DataOwner.CRAWLER, DataOwner.CRAWLER); }