예제 #1
0
        public OwnedBook(IIsbnData isbn, int ownerId, PhysicalCondition condition, Availability availability)
        {
            if (isbn is null)
            {
                throw new ArgumentNullException(nameof(isbn));
            }
            if (ownerId <= 0)
            {
                throw new ArgumentException("The ownerId must be greater than 0.", nameof(ownerId));
            }
            if (!Enum.IsDefined(condition))
            {
                throw new ArgumentException($"Value '{condition}' does not exist in PhysicalCondition");
            }
            if (!Enum.IsDefined(availability))
            {
                throw new ArgumentException($"Value '{availability}' does not exist in Availability");
            }

            Isbn = isbn;

            OwnerId = ownerId;

            Condition = condition;

            Availability = availability;
        }
예제 #2
0
 public PriceEntry(string Vendor, PhysicalCondition Condition, int Quantity, decimal Price)
 {
     vendor = Vendor;
     condition = Condition;
     quantity = Quantity;
     price = Price;
 }
        public void OwnedBook_DefaultUser_Fail()
        {
            // arrange
            PhysicalCondition condition    = PhysicalCondition.LikeNew;
            Availability      availability = Availability.Available;

            // act
            IOwnedBook constructOwnedBook() => new OwnedBook(id, isbn, default, condition, availability);
예제 #4
0
        public OwnedBook(int id, IIsbnData isbn, int ownerId, PhysicalCondition condition, Availability availability) : this(isbn, ownerId, condition, availability)
        {
            if (id <= 0)
            {
                throw new ArgumentException("ID must be greater than or equal to one.");
            }

            Id = id;
        }
예제 #5
0
 public Character(CharacterName name, int number, Body body, Mind mind, SocialCondition socialcondition, PhysicalCondition physicalcondition, CharacterSprites sprites)
 {
     CharacterName            = name;
     CharacterNumber          = number;
     CharacterBody            = body;
     CharacterMind            = mind;
     CharacterSocialCondition = socialcondition;
     PhysicalCondition        = physicalcondition;
     CharacterSprites         = sprites;
 }
        public void OwnedBook_NullIsbn_Fail()
        {
            // arrange
            PhysicalCondition condition    = PhysicalCondition.LikeNew;
            Availability      availability = Availability.Available;

            // act
            IOwnedBook constructOwnedBook() => new OwnedBook(id, null, ownerId, condition, availability);

            // assert
            Assert.Throws <ArgumentNullException>(constructOwnedBook);
        }
 private PriceEntry BestPrice(List<PriceEntry> Prices, PhysicalCondition TargetCondidition)
 {
     PriceEntry result = null;
     foreach (PriceEntry priceEntry in Prices)
     {
         if (priceEntry.Condition > TargetCondidition && (result == null || priceEntry.Price > result.Price))
         {
             result = priceEntry;
         }
     }
     return result;
 }
        public void OwnedBook_Construct_Pass()
        {
            // arrange

            PhysicalCondition condition    = PhysicalCondition.LikeNew;
            Availability      availability = Availability.Available;

            // act
            IOwnedBook ownedBook = new OwnedBook(id, isbn, ownerId, condition, availability);

            // assert
            Assert.NotNull(ownedBook);
        }
예제 #9
0
    private void AssembleCharacter()
    {
        C_CharacterSprites = new CharacterSprites(C_Slug);

        C_WeekRoutine = new WeekRoutine(C_MondayRoutine, C_TuesdayRoutine, C_WednesdayRoutine, C_ThursdayRoutine, C_FridayRoutine, C_SaturdayRoutine, C_SundayRoutine);

        C_Property          = new Property(C_Wealth, C_Incomes, C_Expenses, C_CharacterInventory);
        C_PhysicalTemporal  = new PhysicalTemporal(C_CurrentPosition, C_CurrentTime);
        C_PhysicalCondition = new PhysicalCondition(C_PhysicalTemporal, C_Property, C_WeekRoutine);

        C_SocialCondition = new SocialCondition(C_RelationshipList, C_ReputationList);

        C_Skills = new Skills();

        C_PastLifeEvent  = new PastLifetimeEvent(C_LifeThoughts, C_LifeNeeds, C_LifeMotivation, C_LifeEvent);
        C_PastYearEvent  = new PastYearEvent(C_YearThoughts, C_YearNeeds, C_YearMotivation, C_YearEvent);
        C_PastMonthEvent = new PastMonthEvent(C_MonthThoughts, C_MonthNeeds, C_MonthMotivation, C_MonthEvent);
        C_PastWeekEvent  = new PastWeekEvent(C_WeekThoughts, C_WeekNeeds, C_WeekMotivation, C_WeekEvent);
        C_PastDayEvent   = new PastDayEvent(C_DayThoughts, C_DayNeeds, C_DayMotivation, C_DayEvent);
        C_Memory         = new Memory(C_PastDayEvent, C_PastWeekEvent, C_PastMonthEvent, C_PastYearEvent, C_PastLifeEvent);

        C_CurrentEmotion = new CurrentEmotion(C_CurrentRage, C_CurrentLoathing, C_CurrentGrief, C_CurrentAmazement, C_CurrentTerror, C_CurrentAdmiration, C_CurrentEcstasy, C_CurrentVigilance);

        C_Concept   = new Concept();
        C_Prototype = new Prototype();
        C_Knowledge = new Knowledge();
        C_Morality  = new Morality();
        C_Cognition = new Cognition(C_Concept, C_Prototype, C_Knowledge, C_Morality);

        C_FivePersonality = new FundamentalPersonalityCharacteristics(C_Conscientious, C_Agreeableness, C_Neuroticism, C_Openness, C_Extraversion);
        C_Personality     = new Personality(C_FivePersonality);
        C_Mind            = new Mind(C_Personality, C_Cognition, C_CurrentEmotion, C_Memory, C_MentalHealth, C_Skills);

        C_BodyNeeds      = new BodyNeeds(C_FoodNeeds, C_WaterNeeds, C_SleepNeeds, C_WarmthNeeds, C_ShelterNeeds, C_AirNeeds);
        C_BodyCondition  = new BodyCondition(C_DeathOrAlive, C_ConsciousState, C_MaxEnergy, C_CurrentEnergy, C_BodyNeeds);
        C_Bodyparts      = new BodyParts(C_Sight, C_Hearing, C_Smelling, C_LeftLeg, C_RightLeg, C_LeftArm, C_RightArm);
        C_BasicBodyStats = new BasicBodyStats(C_Race, C_Age, C_Height, C_Sex, C_Bodytype);
        C_Body           = new Body(C_BasicBodyStats, C_Bodyparts, C_BodyCondition);

        C_CharacterName = new CharacterName(C_FirstName, C_LastName, C_Nametype, C_Nickname);
        C_Character     = new Character(C_CharacterName, C_CharacterNumber, C_Body, C_Mind, C_SocialCondition, C_PhysicalCondition, C_CharacterSprites);
    }
예제 #10
0
        public async Task OwnedBookRepository_UpdateStatusOfOwnedBook()
        {
            // arrange
            const int         ownedBookId  = 1;
            const int         userId       = 1;
            const int         bookId       = 1;
            Availability      availability = Availability.CheckedOut;
            PhysicalCondition condition    = PhysicalCondition.Fair;

            using var contextFactory = new TestLooseLeafContextFactory();
            using (LooseLeafContext arrangeContext = contextFactory.CreateContext())
            {
                await contextFactory.CreateOwnedBook(arrangeContext, userId, bookId);

                await arrangeContext.SaveChangesAsync();
            }

            // act
            using (LooseLeafContext actContext = contextFactory.CreateContext())
            {
                IOwnedBookRepository ownedBookRepo = new OwnedBookRepository(actContext);

                await ownedBookRepo.UpdateOwnedBookStatus(ownedBookId, availability, condition);

                await actContext.SaveChangesAsync();
            }

            // assert
            using LooseLeafContext assertContext = contextFactory.CreateContext();
            var ownedBook = await assertContext.OwnedBooks.Include(x => x.User).Include(x => x.Book).SingleAsync();

            Assert.Equal(userId, ownedBook.UserId);
            Assert.Equal(bookId, ownedBook.BookId);
            Assert.Equal((int)condition, ownedBook.ConditionId);
            Assert.Equal((int)availability, ownedBook.AvailabilityStatusId);
        }
예제 #11
0
 public Purchase(PhysicalCondition TargetCondition, Card Card, Printing Printing)
 {
     targetCondition = TargetCondition;
     card = Card;
     printing = Printing;
 }
예제 #12
0
 public Purchase(PhysicalCondition TargetCondition, Card Card)
     : this(TargetCondition, Card, null)
 {
 }
예제 #13
0
    private void JsonToCharacter(int i)
    {
        List <DayRoutine> sundayroutines    = new List <DayRoutine> ();
        List <DayRoutine> saturdayroutines  = new List <DayRoutine> ();
        List <DayRoutine> fridayroutines    = new List <DayRoutine> ();
        List <DayRoutine> thursdayroutines  = new List <DayRoutine> ();
        List <DayRoutine> wednesdayroutines = new List <DayRoutine> ();
        List <DayRoutine> tuesdayroutines   = new List <DayRoutine> ();
        List <DayRoutine> mondayroutines    = new List <DayRoutine> ();

        WeekRoutine weekroutine = new WeekRoutine(mondayroutines, tuesdayroutines, wednesdayroutines, thursdayroutines, fridayroutines, saturdayroutines, sundayroutines);

        CharacterInventory    inventory       = new CharacterInventory();
        List <RegularExpense> regularexpenses = new List <RegularExpense> ();
        List <RegularIncome>  regularincomes  = new List <RegularIncome> ();

        int      wealth   = (int)CurrentJsonData[i]["wealth"];
        Property property = new Property(wealth, regularincomes, regularexpenses, inventory);

        int currentposition = (int)CurrentJsonData[i]["currenttime"];
        int currenttime     = (int)CurrentJsonData[i]["currentposition"];
        PhysicalTemporal physicaltemporal = new PhysicalTemporal(currentposition, currenttime);


        List <Relationship> relationshiplist = new List <Relationship> ();
        List <Reputation>   reputationlist   = new List <Reputation> ();


        List <MentalDisorder> mentalhealth = new List <MentalDisorder> ();
        Skills skills = new Skills();

        List <Event>      pastlifeevents      = new List <Event> ();
        List <Motivation> pastlifemotivations = new List <Motivation> ();
        List <Need>       pastlifeneeds       = new List <Need> ();
        List <Thought>    pastlifethoughts    = new List <Thought> ();

        List <Event>      pastyearevents      = new List <Event> ();
        List <Motivation> pastyearmotivations = new List <Motivation> ();
        List <Need>       pastyearneeds       = new List <Need> ();
        List <Thought>    pastyearthoughts    = new List <Thought> ();

        List <Event>      pastmonthevents      = new List <Event> ();
        List <Motivation> pastmonthmotivations = new List <Motivation> ();
        List <Need>       pastmonthneeds       = new List <Need> ();
        List <Thought>    pastmonththoughts    = new List <Thought> ();

        List <Event>      pastweekevents      = new List <Event> ();
        List <Motivation> pastweekmotivations = new List <Motivation> ();
        List <Need>       pastweekneeds       = new List <Need> ();
        List <Thought>    pastweekthoughts    = new List <Thought> ();

        List <Event>      pastdayevents      = new List <Event> ();
        List <Motivation> pastdaymotivations = new List <Motivation> ();
        List <Need>       pastdayneeds       = new List <Need> ();
        List <Thought>    pastdaythoughts    = new List <Thought> ();

        PastLifetimeEvent pastlife  = new PastLifetimeEvent(pastlifethoughts, pastlifeneeds, pastlifemotivations, pastlifeevents);
        PastYearEvent     pastyear  = new PastYearEvent(pastyearthoughts, pastyearneeds, pastyearmotivations, pastyearevents);
        PastMonthEvent    pastmonth = new PastMonthEvent(pastmonththoughts, pastmonthneeds, pastmonthmotivations, pastmonthevents);
        PastWeekEvent     pastweek  = new PastWeekEvent(pastweekthoughts, pastweekneeds, pastweekmotivations, pastweekevents);
        PastDayEvent      pastday   = new PastDayEvent(pastdaythoughts, pastdayneeds, pastdaymotivations, pastdayevents);
        Memory            memory    = new Memory(pastday, pastweek, pastmonth, pastyear, pastlife);


        int            currentvigilance  = (int)CurrentJsonData[i]["currentvigilance"];
        int            currentecstasy    = (int)CurrentJsonData[i]["currentecstasy"];
        int            currentadmiration = (int)CurrentJsonData[i]["currentadmiration"];
        int            currentterror     = (int)CurrentJsonData[i]["currentterror"];
        int            currentamazement  = (int)CurrentJsonData[i]["currentamazement"];
        int            currentgrief      = (int)CurrentJsonData[i]["currentgrief"];
        int            currentloathing   = (int)CurrentJsonData[i]["currentloathing"];
        int            currentrage       = (int)CurrentJsonData[i]["currentrage"];
        CurrentEmotion emotion           = new CurrentEmotion(currentrage, currentloathing, currentgrief, currentamazement, currentterror, currentadmiration, currentecstasy, currentvigilance);


        Cognition cognition = new Cognition();

        int extraversion      = (int)CurrentJsonData[i]["extraversion"];
        int openness          = (int)CurrentJsonData[i]["openness"];
        int neuroticism       = (int)CurrentJsonData[i]["neuroticism"];
        int agreeableness     = (int)CurrentJsonData[i]["agreeableness"];
        int conscientiousness = (int)CurrentJsonData[i]["conscientiousness"];
        FundamentalPersonalityCharacteristics characteristics = new FundamentalPersonalityCharacteristics(conscientiousness, agreeableness, neuroticism, openness, extraversion);
        Personality personality = new Personality(characteristics);

        int       air     = (int)CurrentJsonData[i]["air"];
        int       shelter = (int)CurrentJsonData[i]["shelter"];
        int       warmth  = (int)CurrentJsonData[i]["warmth"];
        int       sleep   = (int)CurrentJsonData[i]["sleep"];
        int       water   = (int)CurrentJsonData[i]["water"];
        int       food    = (int)CurrentJsonData[i]["food"];
        BodyNeeds needs   = new BodyNeeds(food, water, sleep, warmth, shelter, air);

        int  currentenergy  = (int)CurrentJsonData[i]["currentenergy"];
        int  maxenergy      = (int)CurrentJsonData[i]["maxenergy"];
        int  consciousstate = (int)CurrentJsonData[i]["consciousstate"];
        bool deadoralive    = (bool)CurrentJsonData[i]["deadoralive"];

        BodyCondition bodycondition = new BodyCondition(deadoralive, consciousstate, maxenergy, currentenergy, needs);

        bool      rightarm  = (bool)CurrentJsonData[i]["rightarm"];
        bool      leftarm   = (bool)CurrentJsonData[i]["leftarm"];
        bool      rightleg  = (bool)CurrentJsonData[i]["rightleg"];
        bool      leftleg   = (bool)CurrentJsonData[i]["leftleg"];
        bool      smell     = (bool)CurrentJsonData[i]["smell"];
        bool      hearing   = (bool)CurrentJsonData[i]["hearing"];
        bool      sight     = (bool)CurrentJsonData[i]["sight"];
        BodyParts bodyparts = new BodyParts(sight, hearing, smell, leftleg, rightleg, leftarm, rightarm);

        int            bodytype  = (int)CurrentJsonData[i]["bodytype"];
        int            sex       = (int)CurrentJsonData[i]["sex"];
        int            height    = (int)CurrentJsonData[i]["height"];
        int            age       = (int)CurrentJsonData[i]["age"];
        int            race      = (int)CurrentJsonData[i]["race"];
        BasicBodyStats bodystats = new BasicBodyStats(race, age, height, sex, bodytype);

        string firstname      = (string)CurrentJsonData[i]["firstname"].ToString();
        string lastname       = (string)CurrentJsonData[i]["lastname"].ToString();
        int    nametype       = (int)CurrentJsonData[i]["nametype"];
        string commonnickname = (string)CurrentJsonData[i]["commonnickname"].ToString();

        string slug = (string)CurrentJsonData[i]["slug"].ToString();
        int    id   = (int)CurrentJsonData[i]["id"];

        CharacterName     charactername = new CharacterName(firstname, lastname, nametype, commonnickname);
        Body              body          = new Body(bodystats, bodyparts, bodycondition);
        Mind              mind          = new Mind(personality, cognition, emotion, memory, mentalhealth, skills);
        SocialCondition   social        = new SocialCondition(relationshiplist, reputationlist);
        PhysicalCondition physical      = new PhysicalCondition(physicaltemporal, property, weekroutine);
        CharacterSprites  sprites       = new CharacterSprites(slug);

        Character CurrentCharacter = new Character(charactername, id, body, mind, social, physical, sprites);

        CharacterList.Add(CurrentCharacter);
    }