public void TestAddParent() { var testMother = American.RandomAmerican(new DateTime(1970, 1, 1), Gender.Female); var testChild = American.RandomAmerican(testMother.BirthCert.DateOfBirth.AddYears(25).AddDays(28), Gender.Female); testChild.AddParent(testMother, KindsOfNames.Biological | KindsOfNames.Mother); Assert.AreEqual(1, testChild.Parents.Count()); var testResult = testChild.Parents.FirstOrDefault(c => c.AnyNames(k => k == (KindsOfNames.Biological | KindsOfNames.Mother))); Assert.IsNotNull(testResult); Assert.AreEqual(testMother, testResult.Est); //nothing changes testChild.AddParent(testMother, KindsOfNames.Biological | KindsOfNames.Mother); testResult = testChild.Parents.FirstOrDefault(c => c.AnyNames(k => k == (KindsOfNames.Biological | KindsOfNames.Mother))); Assert.IsNotNull(testResult); Assert.AreEqual(testMother, testResult.Est); //adding a Parent does not add a child Assert.AreEqual(0, testResult.Est.Children.Count()); //cannot add when biological limits are exceeded testMother = American.RandomAmerican(new DateTime(1993, 1, 1), Gender.Female); testChild = American.RandomAmerican(new DateTime(1996, 1, 1), Gender.Female); testChild.AddParent(testMother, KindsOfNames.Mother | KindsOfNames.Biological); Assert.AreEqual(0, testChild.Parents.Count()); }
public void TestGetParent() { var testSubject = American.RandomAmerican(); Assert.IsNotNull(testSubject.Parents); Assert.AreNotEqual(0, testSubject.Parents.Count()); }
public static double[,] optionprice(double S0, double K, double vol, double T, int N, double r, double del, bool type, bool optiontype) { double[,] intrinsic = IntriValues.intrinsicvalues(S0, K, vol, T, N, r, del, type, optiontype); double[,] Option = new double[N + 1, 2 * N + 1]; double[,] american = American.amer(S0, K, vol, T, N, r, del, type, optiontype); if (optiontype)//European: Option price is the same as intrinstic prices { for (int i = 0; i < intrinsic.GetLength(0); i++) { for (int j = 0; j < intrinsic.GetLength(1); j++) { Option[i, j] = intrinsic[i, j]; } } } else//American: Option price is the same as american prices { for (int i = 0; i < intrinsic.GetLength(0); i++) { for (int j = 0; j < intrinsic.GetLength(1); j++) { Option[i, j] = american[i, j]; } } } return(Option); }
public void TestNorthAmericanWithFamily() { var testResult = American.RandomAmerican(DateTime.UtcNow.AddYears(-40), Gender.Female, true); Assert.IsNotNull(testResult.GetBiologicalMother()); Assert.IsNotNull(testResult.GetBiologicalFather()); }
public void TestMakePayment() { var testInput = American.RandomAmerican(Etx.RandomAdultBirthDate(), Gender.Female); var testSubject = new CreditCardAccount(new VisaCc(testInput, DateTime.Today.AddDays(-15), null), CreditCardAccount.DF_MIN_PMT_RATE, new Pecuniam(1800.0M)); Assert.IsTrue(testSubject.Max == new Pecuniam(1800.0M)); }
public void TestAmericanFull() { var testResult = American.RandomAmerican(DateTime.UtcNow.AddYears(-36), Gender.Female, true); Assert.IsNotNull(testResult.GetBiologicalMother()); Assert.AreNotEqual(0, testResult.GetBiologicalMother().GetChildrenAt(null)); }
public IActionResult Update([FromBody] American item) { var session = HttpContext.Get <LoggableEntities>(_context); var current_User = session == null ? null : session.User; var current_Admin = session == null ? null : session.Admin; var allowed_items = ApiTokenValid ? _context.American : _context.American; if (!allowed_items.Any(i => i.Id == item.Id)) { return(Unauthorized()); } var new_item = item; var can_edit_by_token = ApiTokenValid || true; if (item == null || !can_edit_by_token) { return(Unauthorized()); } // throw new Exception("Unauthorized edit attempt"); _context.Update(new_item); _context.Entry(new_item).Property(x => x.CreatedDate).IsModified = false; _context.SaveChanges(); return(Ok()); }
public void AmericanAlligatorImplementsISwim() { //Arrange Vertibrates newAlligator = new American(); //Assert Assert.True(newAlligator is ISwim); }
public void TestGetNorthAmericanEdu() { var testSubject = American.RandomAmerican(); var testEdu = testSubject.GetEducationAt(null); Assert.IsNotNull(testEdu); Console.WriteLine(testEdu); }
static void Main() { Japanese aki = new Japanese(); aki.SayHi(); American tom = new American(); tom.SayHi(); }
static void Main() { Japanese jap = new Japanese(); jap.SayHi(); American ap = new American(); ap.SayHi(); }
public void TestIsPin() { var testSubject = new CheckingAccount("ABC", DateTime.Today.AddDays(-65), new Tuple <ICreditCard, string>( CreditCard.RandomCreditCard(American.RandomAmerican(Etx.RandomAdultBirthDate(), Gender.Female)), "8745")); Assert.IsTrue(testSubject.IsPin("8745")); }
public void TestResolveParents() { var testResult = American.RandomAmerican(DateTime.UtcNow.AddYears(-40), Gender.Female); Assert.IsNull(testResult.GetBiologicalMother()); Assert.IsNull(testResult.GetBiologicalFather()); testResult.ResolveParents(); Assert.IsNotNull(testResult.GetBiologicalMother()); Assert.IsNotNull(testResult.GetBiologicalFather()); }
public void NorthAmericanEduTests() { var amer = American.RandomAmerican(Etx.RandomAdultBirthDate(), Gender.Female); var testResult = amer.GetRandomEducation(); Assert.IsNotNull(testResult); Assert.IsNotNull(testResult.HighSchool); Console.WriteLine(testResult.HighSchool); Console.WriteLine(testResult.College); }
public void AmericanTests() { var testDob = new DateTime(1974, 5, 6); var testResult = American.RandomAmerican(testDob, Gender.Female); Assert.IsNotNull(testResult); Assert.AreNotEqual(Gender.Unknown, testResult.Gender); Assert.IsFalse(string.IsNullOrWhiteSpace(testResult.LastName)); Assert.IsFalse(string.IsNullOrWhiteSpace(testResult.FirstName)); Assert.IsNotNull(testResult.BirthCert); }
public void TestCreditCardCtor() { var testInput = American.RandomAmerican(Etx.RandomAdultBirthDate(), Gender.Female); var testSubject = new VisaCc(testInput, DateTime.Today, null); Assert.IsNotNull(testSubject.Number); Assert.IsFalse(string.IsNullOrWhiteSpace(testSubject.Number.Value)); Assert.IsFalse(string.IsNullOrWhiteSpace(testSubject.CardHolderName)); Assert.IsFalse(string.IsNullOrWhiteSpace(testSubject.Cvv)); System.Diagnostics.Debug.WriteLine(testSubject.ToString()); }
void Start() { GameObject p1 = null; GameObject[] rootObjects = UnityEngine.SceneManagement.SceneManager.GetActiveScene().GetRootGameObjects(); foreach (GameObject i in rootObjects) { if (i.name == "P2") { p1 = i; break; } } other_player = p1.transform.Find("Player2").GetComponent <CharacterBehavior>(); int type = GameSetting.selec_p1; switch (type) { case 0: _skill = new European(this, other_player); break; case 1: _skill = new Korean(this, other_player); break; case 2: _skill = new Egyptian(this, other_player); break; case 3: _skill = new American(this, other_player); break; case 4: _skill = new NorthAmerican(this, other_player); break; default: break; } hearts = new Image[3]; hearts[0] = GameObject.Find("Canvas/P1/P1_heart/P1_heart1").GetComponent <Image>(); hearts[1] = GameObject.Find("Canvas/P1/P1_heart/P1_heart2").GetComponent <Image>(); hearts[2] = GameObject.Find("Canvas/P1/P1_heart/P1_heart3").GetComponent <Image>(); gifts = new Image[3]; gifts[0] = GameObject.Find("Canvas/P1/P1_skill/P1_skillt1").GetComponent <Image>(); gifts[1] = GameObject.Find("Canvas/P1/P1_skill/P1_skillt2").GetComponent <Image>(); gifts[2] = GameObject.Find("Canvas/P1/P1_skill/P1_skillt3").GetComponent <Image>(); StartCoroutine(CheckDie()); StartCoroutine(CheckHp()); StartCoroutine(CheckMp()); StartCoroutine(FinishChecker()); }
public void TestToData() { var testSubject = American.RandomAmerican(DateTime.UtcNow.AddYears(-36), Gender.Female, true); var testResult = testSubject.ToData(KindsOfTextCase.Kabab); Assert.IsNotNull(testResult); Assert.AreNotEqual(0, testResult.Count); foreach (var tr in testResult.Keys) { Console.WriteLine($"{tr}, {testResult[tr]}"); } }
public void TestGetSpouseAt() { //test with full timestamps var firstMarriageDate = new DateTime(DateTime.Today.Year - 15, 8, 8, DateTime.UtcNow.Hour, DateTime.UtcNow.Minute, DateTime.UtcNow.Second); var firstDivorceDate = new DateTime(DateTime.Today.Year - 3, 2, 14, DateTime.UtcNow.Hour, DateTime.UtcNow.Minute, DateTime.UtcNow.Second); var secondMarriageDate = new DateTime((DateTime.Today.Year - 1), 12, 23, DateTime.UtcNow.Hour, DateTime.UtcNow.Minute, DateTime.UtcNow.Second); var testPerson = American.RandomAmerican(new DateTime((DateTime.Today.Year - 42), 6, 20), Gender.Female); var firstSpouse = American.RandomAmerican(new DateTime((DateTime.Today.Year - 46), 4, 4), Gender.Male); testPerson.AddSpouse(firstSpouse, firstMarriageDate, firstDivorceDate); var secondSpouse = American.RandomAmerican(new DateTime((DateTime.Today.Year - 43), 12, 16), Gender.Male); testPerson.AddSpouse(secondSpouse, secondMarriageDate); //expect true when on day-of-wedding var testResult = testPerson.GetSpouseAt(firstMarriageDate); Assert.IsNotNull(testResult); Assert.IsNotNull(testResult.Est); Assert.IsTrue(testResult.Est.Equals(firstSpouse)); //expect false for day of separated testResult = testPerson.GetSpouseAt(firstDivorceDate); Assert.IsNull(testResult); //expect true any time between for (var i = firstMarriageDate.Year + 1; i < firstDivorceDate.Year; i++) { for (var j = 1; j < 13; j++) { testResult = testPerson.GetSpouseAt(new DateTime(i, j, 8)); Assert.IsNotNull(testResult); Assert.IsNotNull(testResult.Est); Assert.IsTrue(testResult.Est.Equals(firstSpouse)); } } //expect false day directly before second marriage testResult = testPerson.GetSpouseAt(secondMarriageDate.Date.AddMilliseconds(-1)); Assert.IsNull(testResult); testResult = testPerson.GetSpouseAt(secondMarriageDate.Date); Assert.IsNotNull(testResult); Assert.IsNotNull(testResult.Est); Assert.IsTrue(testResult.Est.Equals(secondSpouse)); }
public void TestGetRandomMax() { var testInput = American.RandomAmerican(Etx.RandomAdultBirthDate(), Gender.Female); var testSubject = new PersonalCreditScore(testInput.BirthCert.DateOfBirth) { OpennessZscore = testInput.Personality?.Openness?.Value?.Zscore ?? 0D, ConscientiousnessZscore = testInput.Personality?.Conscientiousness?.Value?.Zscore ?? 0D }; var testResult = testSubject.GetRandomMax(null); Debug.WriteLine(testResult); }
public void TestAsPoco() { var dob = Etx.RandomAdultBirthDate(); var gender = Gender.Female; var firstName = AmericanUtil.RandomAmericanFirstName(gender, dob); var middleName = AmericanUtil.RandomAmericanFirstName(gender, dob); var lastName = AmericanUtil.RandomAmericanLastName(); var testSubject = new American { BirthCert = new AmericanBirthCert(dob), Gender = gender, FirstName = firstName, LastName = lastName, MiddleName = middleName }; var addrLine1 = "4455 Deweier St."; var addrLine2 = "Huntington Beach, CA 90802"; PostalAddress.TryParse(addrLine1, addrLine2, out var address); testSubject.AddAddress(address); Assert.AreEqual($"{firstName} {middleName} {lastName}", testSubject.FullName); Assert.IsNotNull(testSubject.Address); Assert.AreEqual($"{addrLine1}\r\n{addrLine2}", testSubject.Address.ToString()); var phNum = "707-884-5563"; NorthAmericanPhone.TryParse(phNum, out var naph); naph.Descriptor = KindsOfLabels.Mobile; testSubject.AddPhone(naph); var testResultPhone = testSubject.PhoneNumbers.FirstOrDefault(p => p.Descriptor == KindsOfLabels.Mobile); Assert.IsNotNull(testResultPhone as NorthAmericanPhone); var namerTestResultPhone = testResultPhone as NorthAmericanPhone; Assert.AreEqual("707", namerTestResultPhone.AreaCode); Assert.AreEqual("884", namerTestResultPhone.CentralOfficeCode); Assert.AreEqual("5563", namerTestResultPhone.SubscriberNumber); var testEmail = "*****@*****.**"; testSubject.AddUri(testEmail); var testResultEmail = testSubject.NetUris.FirstOrDefault(u => u.Scheme == Uri.UriSchemeMailto); Assert.IsNotNull(testResultEmail); Assert.IsTrue(testResultEmail.ToString().EndsWith(testEmail)); }
static void Main(string[] args) { American a = new American(); a.canWalk(); a.canSpeak(); Indian b = new Indian(); b.canWalk(); b.canSpeak(); French c = new French(); c.canWalk(); c.canSpeak(); }
public void TestGetRandomInterestRate() { var testInput = American.RandomAmerican(Etx.RandomAdultBirthDate(), Gender.Female); var testSubject = new PersonalCreditScore(testInput.BirthCert.DateOfBirth) { OpennessZscore = testInput.Personality?.Openness?.Value?.Zscore ?? 0D, ConscientiousnessZscore = testInput.Personality?.Conscientiousness?.Value?.Zscore ?? 0D }; Debug.WriteLine(testSubject.GetScore(new DateTime(DateTime.Today.Year, 1, 1))); var testResult = testSubject.GetRandomInterestRate(new DateTime(DateTime.Today.Year, 1, 1)); Assert.IsTrue(testResult > 3.0D); Debug.WriteLine(testResult); }
// Use this for initialization void Start() { List <Personn> pe = new List <Personn>(); chinese c = new chinese(); American a = new American(); Japanese j = new Japanese(); pe.Add(c); pe.Add(a); pe.Add(j); foreach (Personn item in pe) { item.sayHell0(); } }
public void TestGetMaritalStatus() { var testSubject = American.RandomAmerican(DateTime.UtcNow.AddYears(-40), Gender.Female); var testResult = testSubject.GetMaritalStatusAt(null); Assert.AreNotEqual(MaritalStatus.Unknown, testResult); Console.WriteLine(testResult); testResult = testSubject.GetMaritalStatusAt(DateTime.UtcNow.AddYears(-10)); Assert.AreNotEqual(MaritalStatus.Unknown, testResult); Console.WriteLine(testResult); }
public void TestGetMinPayment() { var testInput = American.RandomAmerican(Etx.RandomAdultBirthDate(), Gender.Female); var testSubject = new CreditCardAccount(new VisaCc(testInput, new DateTime(2014, 1, 11), null), CreditCardAccount.DF_MIN_PMT_RATE, new Pecuniam(1800.0M)); testSubject.MakePurchase(new DateTime(2014, 1, 11), new Pecuniam(63.32M)); testSubject.MakePurchase(new DateTime(2014, 1, 11), new Pecuniam(7.54M)); testSubject.MakePurchase(new DateTime(2014, 1, 12), new Pecuniam(139.47M)); testSubject.MakePurchase(new DateTime(2014, 1, 12), new Pecuniam(2.38M)); testSubject.MakePurchase(new DateTime(2014, 1, 14), new Pecuniam(57.89M)); testSubject.MakePurchase(new DateTime(2014, 1, 14), new Pecuniam(10.09M)); testSubject.MakePurchase(new DateTime(2014, 1, 15), new Pecuniam(7.78M)); testSubject.MakePurchase(new DateTime(2014, 1, 15), new Pecuniam(52.13M)); testSubject.MakePurchase(new DateTime(2014, 1, 15), new Pecuniam(22.95M)); testSubject.MakePurchase(new DateTime(2014, 1, 16), new Pecuniam(47.59M)); testSubject.MakePurchase(new DateTime(2014, 1, 17), new Pecuniam(703.65M)); testSubject.MakePurchase(new DateTime(2014, 1, 17), new Pecuniam(32.11M)); testSubject.MakePurchase(new DateTime(2014, 1, 17), new Pecuniam(12.83M)); testSubject.MakePurchase(new DateTime(2014, 1, 18), new Pecuniam(60.83M)); testSubject.MakePurchase(new DateTime(2014, 1, 20), new Pecuniam(57.64M)); testSubject.MakePurchase(new DateTime(2014, 1, 20), new Pecuniam(49.07M)); testSubject.MakePurchase(new DateTime(2014, 1, 21), new Pecuniam(3.55M)); testSubject.MakePurchase(new DateTime(2014, 1, 24), new Pecuniam(6.94M)); testSubject.MakePurchase(new DateTime(2014, 1, 25), new Pecuniam(6.94M)); testSubject.MakePurchase(new DateTime(2014, 1, 27), new Pecuniam(10.61M)); testSubject.MakePurchase(new DateTime(2014, 1, 27), new Pecuniam(50.73M)); testSubject.MakePurchase(new DateTime(2014, 1, 28), new Pecuniam(8.32M)); var testResult = testSubject.GetMinPayment(new DateTime(2014, 1, 28)); Assert.AreEqual(-17.58M, testResult.Amount); Console.WriteLine(testResult); Console.WriteLine(testSubject.GetValueAt(new DateTime(2014, 1, 28))); testSubject.MakePurchase(new DateTime(2014, 1, 30), new Pecuniam(61.28M)); testSubject.MakePurchase(new DateTime(2014, 2, 1), new Pecuniam(23.11M)); testSubject.MakePurchase(new DateTime(2014, 2, 2), new Pecuniam(9.83M)); testSubject.MakePurchase(new DateTime(2014, 2, 3), new Pecuniam(8.53M)); testSubject.MakePurchase(new DateTime(2014, 2, 3), new Pecuniam(2.09M)); testSubject.MakePurchase(new DateTime(2014, 2, 4), new Pecuniam(7.79M)); testSubject.MakePurchase(new DateTime(2014, 2, 6), new Pecuniam(47.24M)); testSubject.MakePurchase(new DateTime(2014, 2, 7), new Pecuniam(55.95M)); testSubject.MakePurchase(new DateTime(2014, 2, 7), new Pecuniam(30.1M)); testSubject.MakePurchase(new DateTime(2014, 2, 8), new Pecuniam(37.39M)); testSubject.MakePurchase(new DateTime(2014, 2, 10), new Pecuniam(3.91M)); }
public void TestGetRandomBankAccount() { var p = American.RandomAmerican(Etx.RandomAdultBirthDate(), Gender.Female); var testResult = DepositAccount.RandomCheckingAccount(p); Assert.IsNotNull(testResult); Assert.IsNotNull(testResult.Id); System.Diagnostics.Debug.WriteLine(testResult.Id.Value); testResult = DepositAccount.RandomCheckingAccount(p); Assert.IsNotNull(testResult.Id); System.Diagnostics.Debug.WriteLine(testResult.Id.Value); }
public void TestIsValidDobOfChild() { var testPerson = American.RandomAmerican(new DateTime(1955, 6, 20), Gender.Female, false); testPerson.AddChild(American.RandomAmerican(new DateTime(1976, 10, 2), Gender.Female, false)); testPerson.AddChild(American.RandomAmerican(new DateTime(1986, 3, 11), Gender.Female, false)); testPerson.AddChild(American.RandomAmerican(new DateTime(1982, 12, 30), Gender.Female, false)); var testDob = new DateTime(1985, 9, 10);//conception ~ 12/4/1984 var testResult = testPerson.IsValidDobOfChild(testDob); //invalid: dob during prev preg Assert.IsFalse(testResult); testDob = testDob.AddDays(313);//conception ~ 10/13/1985, dob ~ 7/20/1986 //invalid: conception during prev preg testResult = testPerson.IsValidDobOfChild(testDob); Assert.IsFalse(testResult); testDob = testDob.AddDays(313);//conception ~ 8/22/1986, dob 5/29/1987 //valid: conception ~ 5 months after prev birth testResult = testPerson.IsValidDobOfChild(testDob); Assert.IsTrue(testResult); testPerson = American.RandomAmerican(new DateTime(1982, 4, 13), Gender.Female, false); testPerson.AddChild(American.RandomAmerican(new DateTime(2007, 8, 30), Gender.Male)); testPerson.AddChild(American.RandomAmerican(new DateTime(2009, 12, 20), Gender.Female)); testDob = new DateTime(2009, 3, 6); Assert.IsFalse(testPerson.IsValidDobOfChild(testDob)); testDob = testDob.AddDays(280 + 28); Assert.IsFalse(testPerson.IsValidDobOfChild(testDob)); testDob = testDob.AddDays(280 + 28); testResult = testPerson.IsValidDobOfChild(testDob); Assert.IsTrue(testResult); Console.WriteLine(testDob); }
public IActionResult /*American*/ Create() { var session = HttpContext.Get <LoggableEntities>(_context); var current_User = session == null ? null : session.User; var current_Admin = session == null ? null : session.Admin; var can_create_by_token = ApiTokenValid || true; if (!can_create_by_token) { return(Unauthorized()); } // throw new Exception("Unauthorized create attempt"); var item = new American() { CreatedDate = DateTime.Now, Id = _context.Categorie.Max(i => i.Id) + 1 }; _context.American.Add(PortableRecipes.Models.American.FilterViewableAttributesLocal(current_User, current_Admin)(item)); _context.SaveChanges(); item = PortableRecipes.Models.American.WithoutImages(item); return(Ok(item)); }
public void TestAddChild() { var testMother = American.RandomAmerican(new DateTime(1970, 1, 1), Gender.Female); var testChild00 = American.RandomAmerican(testMother.BirthCert.DateOfBirth.AddYears(25).AddDays(28), Gender.Female); testMother.AddChild(testChild00); Assert.AreEqual(1, testMother.Children.Count()); var testChild01 = American.RandomAmerican(testChild00.BirthCert.DateOfBirth.AddDays(28), Gender.Female); //cannot add this child since DoB violates biological constraints testMother.AddChild(testChild01); Assert.AreEqual(1, testMother.Children.Count()); //but this is ok testMother.AddChild(testChild01, KindsOfNames.Mother | KindsOfNames.Adopted); Assert.AreEqual(2, testMother.Children.Count()); //adding child does not add parent Assert.IsNull(testChild01.GetParent(KindsOfNames.Mother | KindsOfNames.Adopted)); }