public void LogSendsAggregateExceptionDetailsToSentryTest() { var name = Guid.NewGuid().ToString(); var sentryId = Guid.NewGuid().ToString(); var eventId = new EventId(Environment.TickCount); var state = new AddressState { Address = Guid.NewGuid().ToString() }; var exception = new AggregateException(Guid.NewGuid().ToString()); exception.AddContextData(state.Address); var client = Substitute.For <IRavenClient>(); client.Capture(Arg.Any <SentryEvent>()).Returns(sentryId); var sut = new SentryLogger(name, client); sut.Log(LogLevel.Critical, eventId, state, exception, (logState, ex) => ex.ToString()); client.Received(1).Capture(Arg.Any <SentryEvent>()); client.Received().Capture(Arg.Is <SentryEvent>(x => x.Level == ErrorLevel.Fatal)); client.Received().Capture(Arg.Is <SentryEvent>(x => x.Exception == exception)); client.Received().Capture(Arg.Is <SentryEvent>(x => x.Message == exception.Message)); client.Logger.Should().Be(name); client.Received().Capture( Arg.Is <SentryEvent>(x => x.Exception.Data["ContextData"].As <string>() == state.Address)); client.Received().Capture( Arg.Is <SentryEvent>(x => x.Exception.Data["CleanedException"].As <string>() == exception.Demystify().ToString())); client.Received().Capture( Arg.Is <SentryEvent>(x => x.Exception.Data["StorageException.RequestInformation"] == null)); }
void ICreditCard.AddParametersToRequest(RestRequest request) { request.AddParameter("card[number]", Number); request.AddParameter("card[exp_month]", ExpMonth); request.AddParameter("card[exp_year]", ExpYear); if (Cvc.HasValue()) { request.AddParameter("card[cvc]", Cvc); } if (Name.HasValue()) { request.AddParameter("card[name]", Name); } if (AddressLine1.HasValue()) { request.AddParameter("card[address_line1]", AddressLine1); } if (AddressLine2.HasValue()) { request.AddParameter("card[address_line2]", AddressLine2); } if (AddressZip.HasValue()) { request.AddParameter("card[address_zip]", AddressZip); } if (AddressState.HasValue()) { request.AddParameter("card[address_state]", AddressState); } if (AddressCountry.HasValue()) { request.AddParameter("card[address_country]", AddressCountry); } }
public void LogSendsExceptionWithContextDataToSentryTest() { var name = Guid.NewGuid().ToString(); var sentryId = Guid.NewGuid().ToString(); var eventId = new EventId(Environment.TickCount); var state = new AddressState { Address = Guid.NewGuid().ToString() }; var exception = new TimeoutException(Guid.NewGuid().ToString()); exception.AddContextData(state.Address); var client = Substitute.For <IRavenClient>(); client.Capture(Arg.Any <SentryEvent>()).Returns(sentryId); var sut = new SentryLogger(name, client); sut.Log(LogLevel.Critical, eventId, state, exception, (logState, ex) => ex.ToString()); client.Received(1).Capture(Arg.Any <SentryEvent>()); client.Received().Capture( Arg.Is <SentryEvent>(x => x.Exception.Data["ContextData"].As <string>().Contains(state.Address))); }
public List <AddressState> GetStates() { List <AddressState> states = new List <AddressState>(); using (var cn = new SqlConnection("Server=localhost;Database=GuildCars;User Id=sa;Password=sqlserver;")) { SqlCommand cmd = new SqlCommand("DisplayStates", cn); cmd.CommandType = CommandType.StoredProcedure; cn.Open(); using (SqlDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { AddressState currentRow = new AddressState(); currentRow.StateId = dr["StateId"].ToString(); currentRow.StateName = dr["StateName"].ToString(); states.Add(currentRow); } } } return(states); }
public void LogSendsMessageToSentryTest() { var name = Guid.NewGuid().ToString(); var sentryId = Guid.NewGuid().ToString(); var message = Guid.NewGuid().ToString(); var state = new AddressState { Address = Guid.NewGuid().ToString() }; var exception = new TimeoutException(Guid.NewGuid().ToString()); exception.AddContextData(state.Address); var client = Substitute.For <IRavenClient>(); client.Capture(Arg.Any <SentryEvent>()).Returns(sentryId); var sut = new SentryLogger(name, client); sut.LogError(exception, message); client.Received(1).Capture(Arg.Any <SentryEvent>()); client.Received().Capture(Arg.Is <SentryEvent>(x => x.Level == ErrorLevel.Error)); client.Received().Capture(Arg.Is <SentryEvent>(x => x.Exception == exception)); client.Received().Capture(Arg.Is <SentryEvent>(x => x.Message == exception.Message)); client.Logger.Should().Be(name); client.Received().Capture( Arg.Is <SentryEvent>(x => x.Exception.Data["FormattedMessage"].As <string>() == message)); }
public void LogSendsIncludesComplexPropertyWhenExtractingAdditionalDataTest() { var name = Guid.NewGuid().ToString(); var sentryId = Guid.NewGuid().ToString(); var eventId = new EventId(Environment.TickCount); var state = new AddressState { Address = Guid.NewGuid().ToString() }; var company = Model.Create <Company>(); var exception = new EmptyException { Company = company }; var client = Substitute.For <IRavenClient>(); client.Capture(Arg.Any <SentryEvent>()).Returns(sentryId); var sut = new SentryLogger(name, client); sut.Log(LogLevel.Critical, eventId, state, exception, (logState, ex) => ex.ToString()); client.Received(1).Capture(Arg.Any <SentryEvent>()); client.Received().Capture( Arg.Is <SentryEvent>(x => x.Exception.Data.Contains("EmptyException.Company"))); }
public void LogSendsNestedExceptionDetailsToSentryTest() { var value = Guid.NewGuid().ToString(); var sentryId = Guid.NewGuid().ToString(); var name = Guid.NewGuid().ToString(); var eventId = new EventId(Environment.TickCount); var state = new AddressState { Address = Guid.NewGuid().ToString() }; var innerException = Model.Ignoring <ValueTypeException>(x => x.Data).Create <ValueTypeException>() .Set(x => x.Id = value); var exception = new ArgumentNullException(Guid.NewGuid().ToString(), innerException); exception.AddContextData(state.Address); var client = Substitute.For <IRavenClient>(); client.Capture(Arg.Any <SentryEvent>()).Returns(sentryId); var sut = new SentryLogger(name, client); sut.Log(LogLevel.Critical, eventId, state, exception, (logState, ex) => ex.ToString()); client.Received().Capture( Arg.Is <SentryEvent>(x => x.Exception.Data["ValueTypeException.Id"].As <string>() == value)); }
// // GET: /Home/ public ActionResult Index() { var colorado = new AddressState { StateId = 1, StateAbbreviation = "CO" }; var missouri = new AddressState { StateId = 2, StateAbbreviation = "MO" }; var person = new Person { PersonId = 0, FirstName = "Stan", LastName = "Butler", MyAddress = new Address { AddressId = 0, Address1 = "519 Spruce", City = "Kansas City", State = missouri, Zip = "64122", States = new [] { colorado, missouri } } }; return(View(person)); }
public async Task <IActionResult> Edit(Guid id, [Bind("StateId,Name,StateAbbreviation,CreatedOn,UpdatedOn")] AddressState addressState) { if (id != addressState.StateId) { return(NotFound()); } if (ModelState.IsValid) { try { await _addressStateService.UpdateAddress(addressState); } catch (DbUpdateConcurrencyException) { if (!AddressStateExists(addressState.StateId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(addressState)); }
public void LogSendsValueTypeExceptionPropertiesAsDataTest() { var name = Guid.NewGuid().ToString(); var sentryId = Guid.NewGuid().ToString(); var eventId = new EventId(Environment.TickCount); var state = new AddressState { Address = Guid.NewGuid().ToString() }; var exception = Model.Ignoring <ValueTypeException>(x => x.Data).Create <ValueTypeException>(); var client = Substitute.For <IRavenClient>(); client.Capture(Arg.Any <SentryEvent>()).Returns(sentryId); var sut = new SentryLogger(name, client); sut.Log(LogLevel.Critical, eventId, state, exception, (logState, ex) => ex.ToString()); client.Received().Capture( Arg.Is <SentryEvent>(x => x.Exception.Data["ValueTypeException.Day"].As <DayOfWeek>() == exception.Day)); client.Received().Capture( Arg.Is <SentryEvent>(x => x.Exception.Data["ValueTypeException.Number"].As <int>() == exception.Number)); client.Received().Capture( Arg.Is <SentryEvent>(x => x.Exception.Data["ValueTypeException.Id"].As <string>() == exception.Id)); client.Received().Capture( Arg.Is <SentryEvent>( x => x.Exception.Data["ValueTypeException.When"].As <DateTimeOffset>() == exception.When)); }
public void LogStoresSentryIdInExceptionDataTest() { var expected = Guid.NewGuid().ToString(); var name = Guid.NewGuid().ToString(); var eventId = new EventId(Environment.TickCount); var state = new AddressState { Address = Guid.NewGuid().ToString() }; var exception = new TimeoutException(Guid.NewGuid().ToString()); exception.AddContextData(state.Address); var client = Substitute.For <IRavenClient>(); client.Capture(Arg.Any <SentryEvent>()).Returns(expected); var sut = new SentryLogger(name, client); sut.Log(LogLevel.Critical, eventId, state, exception, (logState, ex) => ex.ToString()); var actual = exception.Data["Sentry_Id"] as string; actual.Should().Be(expected); }
public void LogIgnoresFailureToReadPropertiesForExceptionDataTest() { var name = Guid.NewGuid().ToString(); var sentryId = Guid.NewGuid().ToString(); var eventId = new EventId(Environment.TickCount); var state = new AddressState { Address = Guid.NewGuid().ToString() }; var exception = Model.Ignoring <ReadFailureException>(x => x.Data) .Ignoring <ReadFailureException>(x => x.Failure).Ignoring <ReadFailureException>(x => x.State) .Create <ReadFailureException>(); var client = Substitute.For <IRavenClient>(); client.Capture(Arg.Any <SentryEvent>()).Returns(sentryId); var sut = new SentryLogger(name, client); sut.Log(LogLevel.Critical, eventId, state, exception, (logState, ex) => ex.ToString()); client.Received().Capture( Arg.Is <SentryEvent>( x => x.Exception.Data["ReadFailureException.Before"].As <string>() == exception.Before)); client.Received().Capture( Arg.Is <SentryEvent>(x => x.Exception.Data.Contains("ReadFailureException.Failure") == false)); client.Received().Capture( Arg.Is <SentryEvent>( x => x.Exception.Data["ReadFailureException.Other"].As <string>() == exception.Other)); }
public void ChangeState(AddressState state) { if (State == state) { throw new InvalidOperationException(" the address state equals with the arguement"); } State = state; }
/// <summary> /// Initializes a new instance of the <see cref="Address"/> class. /// </summary> /// <param name="addressState">State of the address.</param> internal Address(AddressState addressState) { AddressLine1 = addressState.AddressLine1; AddressLine2 = addressState.AddressLine2; City = addressState.City; State = addressState.State; ZipCode = addressState.ZipCode; }
public async Task <IActionResult> Create([Bind("StateId,Name,StateAbbreviation,CreatedOn,UpdatedOn")] AddressState addressState) { if (ModelState.IsValid) { await _addressStateService.SetAddress(addressState); return(RedirectToAction(nameof(Index))); } return(View(addressState)); }
public bool SaveTransaction(Transaction tx) { Coin[] changeset; lock (contracts) lock (coins) { if (tx.Inputs.Any(p => !coins.Contains(p) || coins[p].State.HasFlag(CoinState.Spent) || !coins[p].State.HasFlag(CoinState.Confirmed))) { return(false); } foreach (CoinReference input in tx.Inputs) { coins[input].State |= CoinState.Spent; coins[input].State &= ~CoinState.Confirmed; } for (ushort i = 0; i < tx.Outputs.Length; i++) { AddressState state = CheckAddressState(tx.Outputs[i].ScriptHash); if (state.HasFlag(AddressState.InWallet)) { Coin coin = new Coin { Reference = new CoinReference { PrevHash = tx.Hash, PrevIndex = i }, Output = tx.Outputs[i], State = CoinState.Unconfirmed }; if (state.HasFlag(AddressState.WatchOnly)) { coin.State |= CoinState.WatchOnly; } coins.Add(coin); } } if (tx is ClaimTransaction) { foreach (CoinReference claim in ((ClaimTransaction)tx).Claims) { coins[claim].State |= CoinState.Claimed; coins[claim].State &= ~CoinState.Confirmed; } } changeset = coins.GetChangeSet(); OnSaveTransaction(tx, changeset.Where(p => ((ITrackable <CoinReference>)p).TrackState == TrackState.Added), changeset.Where(p => ((ITrackable <CoinReference>)p).TrackState == TrackState.Changed)); coins.Commit(); } if (changeset.Length > 0) { BalanceChanged?.Invoke(this, EventArgs.Empty); } return(true); }
public async Task <AddressState> UpdateAddress(AddressState AddressState) { AddressState.UpdatedBy = await _userManager.GetUserAsync(_contextAccessor.HttpContext.User); AddressState.UpdatedOn = DateTime.UtcNow; _context.Update(AddressState); await _context.SaveChangesAsync(); return(AddressState); }
public static AddressState CreateAddressState(string countryRegionId, string state, global::Microsoft.Dynamics.DataEntities.AddressCountryRegion countryRegion) { AddressState addressState = new AddressState(); addressState.CountryRegionId = countryRegionId; addressState.State = state; if ((countryRegion == null)) { throw new global::System.ArgumentNullException("countryRegion"); } addressState.CountryRegion = countryRegion; return(addressState); }
public ActionResult Index(Person model) { var colorado = new AddressState { StateId = 1, StateAbbreviation = "CO" }; var missouri = new AddressState { StateId = 2, StateAbbreviation = "MO" }; model.MyAddress.States = new[] { colorado, missouri }; return(View(model)); }
public void LogSendsTypeReflectionLoadExceptionWithAdditionalContentTest() { var name = Guid.NewGuid().ToString(); var sentryId = Guid.NewGuid().ToString(); var eventId = new EventId(Environment.TickCount); var state = new AddressState { Address = Guid.NewGuid().ToString("N") }; var first = Model.Ignoring <ValueTypeException>(x => x.Data).Create <ValueTypeException>(); var second = Model.Ignoring <WithNestedClassException>(x => x.Data).Create <WithNestedClassException>(); var innerException = new ReflectionTypeLoadException( new[] { typeof(string), typeof(int) }, new Exception[] { first, second }); var exception = new AggregateException(Guid.NewGuid().ToString(), innerException); exception.AddContextData(state.Address); var client = Substitute.For <IRavenClient>(); client.Capture(Arg.Any <SentryEvent>()).Returns(sentryId); var sut = new SentryLogger(name, client); sut.Log(LogLevel.Critical, eventId, state, exception, (logState, ex) => ex.ToString()); client.Received().Capture( Arg.Is <SentryEvent>( x => x.Exception.Data["ReflectionTypeLoadException.Types"].As <string>() .Contains(innerException.Types[0].AssemblyQualifiedName))); client.Received().Capture( Arg.Is <SentryEvent>( x => x.Exception.Data["ReflectionTypeLoadException.Types"].As <string>() .Contains(innerException.Types[1].AssemblyQualifiedName))); client.Received().Capture( Arg.Is <SentryEvent>( x => x.Exception.Data["ReflectionTypeLoadException.LoaderExceptions"].As <string>() .Contains(innerException.LoaderExceptions[0].GetType().Name))); client.Received().Capture( Arg.Is <SentryEvent>( x => x.Exception.Data["ReflectionTypeLoadException.LoaderExceptions"].As <string>() .Contains(innerException.LoaderExceptions[1].GetType().Name))); }
void IObjectValidation.AddParametersToRequest(RestRequest request) { if (Token.HasValue()) { request.AddParameter("source", Token); } else { request.AddParameter("source[object]", "card"); request.AddParameter("source[number]", Number); request.AddParameter("source[exp_month]", ExpMonth); request.AddParameter("source[exp_year]", ExpYear); if (Cvc.HasValue()) { request.AddParameter("source[cvc]", Cvc); } if (Name.HasValue()) { request.AddParameter("source[name]", Name); } if (AddressLine1.HasValue()) { request.AddParameter("source[address_line1]", AddressLine1); } if (AddressLine2.HasValue()) { request.AddParameter("source[address_line2]", AddressLine2); } if (AddressCity.HasValue()) { request.AddParameter("source[address_city]", AddressCity); } if (AddressState.HasValue()) { request.AddParameter("source[address_state]", AddressState); } if (AddressZip.HasValue()) { request.AddParameter("source[address_zip]", AddressZip); } if (AddressCountry.HasValue()) { request.AddParameter("source[address_country]", AddressCountry); } } }
public void LogDoesNotSendEntryToSentryWhenExceptionIsNullTest() { var name = Guid.NewGuid().ToString(); var eventId = new EventId(Environment.TickCount); var state = new AddressState { Address = Guid.NewGuid().ToString() }; var client = Substitute.For <IRavenClient>(); var sut = new SentryLogger(name, client); sut.Log(LogLevel.Critical, eventId, state, null, (logState, ex) => ex.ToString()); client.DidNotReceive().Capture(Arg.Any <SentryEvent>()); }
public PatientDemographic ToAnonymousPatientDemographic() { return(new PatientDemographic { PersonId = PersonId, AddressPostalCode = AddressPostalCode.ValueElseUnknown(), AddressState = AddressState.ValueElseUnknown(), Ethnicity = Ethnicity.ValueElseUnknown(), Gender = Gender.ValueElseUnknown(), Age = Age > 89 ? 89 : Age, Language = Language.ValueElseUnknown(), MaritalStatus = MaritalStatus.ValueElseUnknown(), Race = Race.ValueElseUnknown(), Religion = Religion.ValueElseUnknown(), IsMarried = IsMarried, IsHispanic = IsHispanic, IsDeceased = IsDeceased }); }
public void LogSendsExceptionToSentryTest(LogLevel logLevel) { var name = Guid.NewGuid().ToString(); var sentryId = Guid.NewGuid().ToString(); var eventId = new EventId(Environment.TickCount); var state = new AddressState { Address = Guid.NewGuid().ToString() }; var exception = new TimeoutException(Guid.NewGuid().ToString()); var expectedLevel = ErrorLevel.Debug; if (logLevel == LogLevel.Critical) { expectedLevel = ErrorLevel.Fatal; } else if (logLevel == LogLevel.Information) { expectedLevel = ErrorLevel.Info; } else if (Enum.IsDefined(typeof(ErrorLevel), logLevel.ToString())) { expectedLevel = (ErrorLevel)Enum.Parse(typeof(ErrorLevel), logLevel.ToString()); } var client = Substitute.For <IRavenClient>(); client.Capture(Arg.Any <SentryEvent>()).Returns(sentryId); var sut = new SentryLogger(name, client); sut.Log(logLevel, eventId, state, exception, (logState, ex) => ex.ToString()); client.Received(1).Capture(Arg.Any <SentryEvent>()); client.Received().Capture(Arg.Is <SentryEvent>(x => x.Level == expectedLevel)); client.Received().Capture(Arg.Is <SentryEvent>(x => x.Exception == exception)); client.Received().Capture(Arg.Is <SentryEvent>(x => x.Message == exception.Message)); client.Logger.Should().Be(name); client.Received().Capture(Arg.Is <SentryEvent>(x => x.Exception.Data["ContextData"] == null)); client.Received().Capture(Arg.Is <SentryEvent>(x => x.Exception.Data["AsyncException"] == null)); client.Received().Capture(Arg.Is <SentryEvent>(x => x.Exception.Data["StorageException"] == null)); }
public void LogDoesNotIncludeNullNestedTypeInExceptionDataTest() { var name = Guid.NewGuid().ToString(); var sentryId = Guid.NewGuid().ToString(); var eventId = new EventId(Environment.TickCount); var state = new AddressState { Address = Guid.NewGuid().ToString() }; var exception = Model.Ignoring <WithNestedClassException>(x => x.Data).Create <WithNestedClassException>() .Set(x => x.State = null); var client = Substitute.For <IRavenClient>(); client.Capture(Arg.Any <SentryEvent>()).Returns(sentryId); var sut = new SentryLogger(name, client); sut.Log(LogLevel.Critical, eventId, state, exception, (logState, ex) => ex.ToString()); client.Received().Capture( Arg.Is <SentryEvent>(x => x.Exception.Data.Contains("WithNestedClassException.State") == false)); }
public void LogDoesNotIncludeCustomStringDataWithoutValueTest(string value) { var sentryId = Guid.NewGuid().ToString(); var name = Guid.NewGuid().ToString(); var eventId = new EventId(Environment.TickCount); var state = new AddressState { Address = Guid.NewGuid().ToString() }; var exception = Model.Ignoring <ValueTypeException>(x => x.Data).Create <ValueTypeException>() .Set(x => x.Id = value); var client = Substitute.For <IRavenClient>(); client.Capture(Arg.Any <SentryEvent>()).Returns(sentryId); var sut = new SentryLogger(name, client); sut.Log(LogLevel.Critical, eventId, state, exception, (logState, ex) => ex.ToString()); client.Received().Capture( Arg.Is <SentryEvent>(x => x.Exception.Data.Contains("ValueTypeException.Id") == false)); }
public PatientDemographic ToIdentifiedPatientDemographic() { return(new PatientDemographic { PersonId = PersonId, AddressPostalCode = AddressPostalCode.ValueElseUnknown(), AddressState = AddressState.ValueElseUnknown(), Ethnicity = Ethnicity.ValueElseUnknown(), Gender = Gender.ValueElseUnknown(), Age = Age, Language = Language.ValueElseUnknown(), MaritalStatus = MaritalStatus.ValueElseUnknown(), Race = Race.ValueElseUnknown(), Religion = Religion.ValueElseUnknown(), IsMarried = IsMarried, IsHispanic = IsHispanic, IsDeceased = IsDeceased, BirthDate = BirthDate, DeceasedDateTime = DeceasedDateTime, Name = Name.ValueElseUnknown(), Mrn = Mrn.ValueElseUnknown() }); }
public void LogSendsToSentryWithoutNullFormattedMessageTest() { var name = Guid.NewGuid().ToString(); var sentryId = Guid.NewGuid().ToString(); var state = new AddressState { Address = Guid.NewGuid().ToString() }; var exception = new TimeoutException(Guid.NewGuid().ToString()); exception.AddContextData(state.Address); var client = Substitute.For <IRavenClient>(); client.Capture(Arg.Any <SentryEvent>()).Returns(sentryId); var sut = new SentryLogger(name, client); sut.LogError(exception, null); client.Received(1).Capture(Arg.Any <SentryEvent>()); client.Received().Capture( Arg.Is <SentryEvent>(x => x.Exception.Data.Contains("FormattedMessage") == false)); }
private void ProcessNewBlock(Block block) { Coin[] changeset; lock (contracts) lock (coins) { foreach (Transaction tx in block.Transactions) { for (ushort index = 0; index < tx.Outputs.Length; index++) { TransactionOutput output = tx.Outputs[index]; AddressState state = CheckAddressState(output.ScriptHash); if (state.HasFlag(AddressState.InWallet)) { CoinReference key = new CoinReference { PrevHash = tx.Hash, PrevIndex = index }; if (coins.Contains(key)) { coins[key].State |= CoinState.Confirmed; } else { coins.Add(new Coin { Reference = key, Output = output, State = CoinState.Confirmed }); } if (state.HasFlag(AddressState.WatchOnly)) { coins[key].State |= CoinState.WatchOnly; } } } } foreach (Transaction tx in block.Transactions) { foreach (CoinReference input in tx.Inputs) { if (coins.Contains(input)) { if (coins[input].Output.AssetId.Equals(Blockchain.SystemShare.Hash)) { coins[input].State |= CoinState.Spent | CoinState.Confirmed; } else { coins.Remove(input); } } } } foreach (ClaimTransaction tx in block.Transactions.OfType <ClaimTransaction>()) { foreach (CoinReference claim in tx.Claims) { if (coins.Contains(claim)) { coins.Remove(claim); } } } current_height++; changeset = coins.GetChangeSet(); OnProcessNewBlock(block, changeset.Where(p => ((ITrackable <CoinReference>)p).TrackState == TrackState.Added), changeset.Where(p => ((ITrackable <CoinReference>)p).TrackState == TrackState.Changed), changeset.Where(p => ((ITrackable <CoinReference>)p).TrackState == TrackState.Deleted)); coins.Commit(); } if (changeset.Length > 0) { BalanceChanged?.Invoke(this, EventArgs.Empty); } }