Esempio n. 1
0
        void WhenComparingCurrentAgeWithSameAge_ShouldBeZero()
        {
            var value1 = new CurrentAge(1);
            var value2 = value1;

            Assert.True(value1.CompareTo(value2) == 0);
        }
Esempio n. 2
0
        void WhenComparingCurrentAgeWithLesserAge_ShouldBePositive()
        {
            var value1 = new CurrentAge(1);
            var value2 = new CurrentAge(2);

            Assert.True(value2.CompareTo(value1) > 0);
            Assert.True(value2 > value1);
        }
Esempio n. 3
0
        void WhenComparingCurrentAgeWithGreaterAge_ShouldBeNegative()
        {
            var value1 = new CurrentAge(1);
            var value2 = new CurrentAge(2);

            Assert.True(value1.CompareTo(value2) < 0);
            Assert.True(value1 < value2);
        }
Esempio n. 4
0
    Int32 DisplaySuperHeros(string SearchParameter)
    {
        //clear the listbox
        lstDefaultDetails.Items.Clear();
        //string variable to display "Super Speed"
        string SuperSpeed = "";
        //string variable to display "Super Strength"
        string SuperStrength = "";
        //string variable to display "Super Flight"
        string SuperFlight = "";
        //string variable to display "Super Teleportation"
        string SuperTeleportation = "";
        //string variable to display "Super Invisibility"
        string SuperInvisibility = "";
        //string variable to display "Super Telekenisis"
        string SuperTelekenisis = "";
        //string variable to display "Super Psychokenisis"
        string SuperPsychokenisis = "";
        //variable to store the primary key
        Int32 SuperHeroID;
        //string variable for the Nickname
        String Nickname;
        //string variable for the Gender
        String Gender;
        //decimal variable to store Height_m
        Decimal Height;
        //integer variable to store Weight_kg
        Int32 Weight_kg;
        //DateTime variable to store birthdate
        DateTime BirthDate;
        //[27/02/2019] This line was added after the FormatDate function was created, so date can be displayed nicely in DD/MM/YYYY
        //string variable stores the formated date to be displayed
        String DisplayDate;
        //foreign key reference for City name in the SuperHeros Database (stored as a string value, thats why CityNo is a string)
        Int32 CityNo;
        //string variable to store the City name that will be retrieved from the City database using the CityNo
        string CityName;
        //Int32 Age;          // variable for the Age is obscelete as the age is now calculated from the date
        //boolean value to store the boolean for speed in data base
        Boolean Speed;
        //boolean value to store the boolean for strength
        Boolean Strength;
        //boolean value to store the boolean for flight
        Boolean Flight;
        //boolean value to store the boolean for teleportation
        Boolean Teleportation;
        //boolean value to store the boolean for invisibility
        Boolean Invisibility;
        //boolean value to store the boolean for telekenisis
        Boolean Telekenisis;
        //boolean value to store the boolean for psychokenisis
        Boolean Psychokenisis;
        //integer variable to store age which will be calculated from the BirthDate and CurrentDate
        Int32 CurrentAge;
        //create an instance of the clsSuperHeroCollection class to give us access to data we need.
        ///The list is populated when we create an intsance of the class.
        ///create a SuperHeroCollection object, to get access to methods
        clsSuperHeroCollection newSuperHeroCollection = new clsSuperHeroCollection();

        //execute the search method in the object, passing the search parameter
        //returns the number of records in newSuperHeroCollection and assigned to recordCount variable
        newSuperHeroCollection.SearchSuperHeros(SearchParameter);
        //declare integet to store the record count
        Int32 recordCount;

        recordCount = newSuperHeroCollection.Count;
        //initialise the Variable to store the index of the loop (used to point to SuperHero data we want)
        Int32 Pointer = 0;
        //declare a new instance of the newSuperHero so that we can use it to access functions for calculate age and format date
        clsSuperHero newSuperHero = new clsSuperHero();

        //while loop that traverses the rows and gets the dat in each (named) column
        while (Pointer < recordCount)
        {
            /// obtain the desired data from the populated superHeroList from the instance of clsSuperHeroCollection
            /// newSuperHeroCollection is the instance of clsSuperHeroCollection to will
            //Get primary key from the data table
            SuperHeroID = newSuperHeroCollection.SuperHeroList[Pointer].SuperHeroID;
            //get Nickname from the data table
            Nickname = newSuperHeroCollection.SuperHeroList[Pointer].Nickname;
            //get Gender from the data table
            Gender = newSuperHeroCollection.SuperHeroList[Pointer].Gender;
            //get the weight from the data table
            Weight_kg = newSuperHeroCollection.SuperHeroList[Pointer].Weight_kg;
            //get the height from the datatable
            Height = newSuperHeroCollection.SuperHeroList[Pointer].Height_m;
            //get the birthdate from the data table
            BirthDate = newSuperHeroCollection.SuperHeroList[Pointer].BirthDate;
            //[27/01/2019] Formats and assigns date to the DisplayDate string.
            DisplayDate = newSuperHero.FormatDate(BirthDate);
            //[27/01/2019] Following code is obscelete as the age can be calculated directly
            //Age = newSuperHeroCollection.SuperHeroList[Pointer].Age; // get age
            //calculates the current age based on BirthDate and CurrentDate
            CurrentAge = newSuperHero.CalculateAge(BirthDate, DateTime.Today);
            //[02/02/2019] Adding the clsCityCollection and clsCity classes and having a seperate database for cities for the cities drop down list (in Profile.aspx)
            //meant SelectedValue for the Cities drop down list is passed to the database table for SuperHeros rather than the name.
            //the CityNo is being used as a foriegn key in the SuperHeros database and therefore when copied from the database a number appears in the listbox in Default.aspx.
            //However this number can be converted back to the city name by creating an instance of the clsCityCollection, which can then be used to copy city from the datatable.
            //Get the foreign key CityNo (now stored in City) from the SuperHeros database and convert it to an integer
            CityNo = newSuperHeroCollection.SuperHeroList[Pointer].CityNo;
            //create an instance of the clsCityCollection to work with
            clsCityCollection theCities = new clsCityCollection();
            //Pass in the search parameter (to populate the the list array object called CitiesList)
            theCities.CitySearchParameter(CityNo);
            //Get the CityName to be displayed based on the CityNo
            CityName = theCities.CityList[0].CityName;
            //get the boolean value of speed thats in the datatable
            Speed = newSuperHeroCollection.SuperHeroList[Pointer].Speed;
            //if the value is true, assign some text, else assign nothing
            if (Speed == true)
            {
                SuperSpeed = ", Super Speed";
            }
            else
            {
                SuperSpeed = "";
            }
            //get the boolean value of Strength thats in the datatable
            Strength = newSuperHeroCollection.SuperHeroList[Pointer].Strength;
            //if the value is true, assign some text, else assign nothing
            if (Strength == true)
            {
                SuperStrength = ", Super Strength";
            }
            else
            {
                SuperStrength = "";
            }
            //get the boolean value of Flight thats in the datatable
            Flight = newSuperHeroCollection.SuperHeroList[Pointer].Flight;
            //if the value is true, assign some text, else assign nothing
            if (Flight == true)
            {
                SuperFlight = ", Flight";
            }
            else
            {
                SuperFlight = "";
            }
            //get the boolean value of Teleportation thats in the datatable
            Teleportation = newSuperHeroCollection.SuperHeroList[Pointer].Teleportation;
            //if the value is true, assign some text, else assign nothing
            if (Teleportation == true)
            {
                SuperTeleportation = ", Teleportation";
            }
            else
            {
                SuperTeleportation = "";
            }
            //get the boolean value of Invisibility thats in the datatable
            Invisibility = newSuperHeroCollection.SuperHeroList[Pointer].Invisibility;
            //if the value is true, assign some text, else assign nothing
            if (Invisibility == true)
            {
                SuperInvisibility = ", Invisibility";
            }
            else
            {
                SuperInvisibility = "";
            }
            //get the boolean value of Telekenisis thats in the datatable
            Telekenisis = newSuperHeroCollection.SuperHeroList[Pointer].Telekenisis;
            //if the value is true, assign some text, else assign nothing
            if (Telekenisis == true)
            {
                SuperTelekenisis = ", Telekenisis";
            }
            else
            {
                SuperTelekenisis = "";
            }
            //get the boolean value of Psychokenisis thats in the datatable
            Psychokenisis = newSuperHeroCollection.SuperHeroList[Pointer].Psychokenisis;
            //if the value is true, assign some text, else assign nothing
            if (Psychokenisis == true)
            {
                SuperPsychokenisis = ", Psychokenisis";
            }
            else
            {
                SuperPsychokenisis = "";
            }

            ///List item is defined: public ListItem (string text, string value);
            ///https://docs.microsoft.com/en-us/dotnet/api/system.web.ui.webcontrols.listitem.-ctor?view=netframework-4.7.2#System_Web_UI_WebControls_ListItem__ctor

            ///Initialise a new instance of list item with the concatenated string of data we want to display as the first parameter in ListItem instance
            ///The value of list item is the primary key, we convert to string and add as the second parameter to ListItem instance
            ///Each List item will be displayed in the format Nickname, gender, age.
            ListItem newListItem = new ListItem("Superhero ID [" + SuperHeroID.ToString() + "] " + Nickname + ": " + Gender + ", " + Height.ToString() + "m tall" + ", " + Weight_kg + "kg" + ", " + "born " + DisplayDate + ", " + CurrentAge.ToString() + " years old, " + " lives in " + CityName + SuperFlight + SuperInvisibility + SuperSpeed + SuperStrength + SuperTelekenisis + SuperTeleportation + SuperPsychokenisis, SuperHeroID.ToString());

            ///add the item to the list menu
            lstDefaultDetails.Items.Add(newListItem);

            /// increment pointer so it points to next superhero in the collection class
            Pointer++;
        }
        return(recordCount);
    }
Esempio n. 5
0
        override public String EvaluateDataBinding(String bindingContext)
        {
            String dataValue = String.Empty;

            String bindingContextPart = bindingContext.Split('.')[0];

            switch (bindingContextPart)
            {
            case "ExternalMemberId": dataValue = (Entity != null) ? Entity.UniqueId : String.Empty; break;

            case "Entity":

                if (bindingContext == "Entity.Id")
                {
                    dataValue = entityId.ToString();
                }

                else
                {
                    dataValue = Entity.EvaluateDataBinding(bindingContext.Replace(bindingContextPart + ".", ""));
                }

                break;

            case "BirthDate": dataValue = birthDate.ToString("MM/dd/yyyy"); break;

            case "DeathDate": if (!deathDate.HasValue)
                {
                    dataValue = String.Empty;
                }
                else
                {
                    dataValue = deathDate.Value.ToString("MM/dd/yyyy");
                } break;

            case "CurrentAge": dataValue = CurrentAge.ToString(); break;

            case "Gender": dataValue = gender; break;

            case "GenderDescription": dataValue = GenderDescription; break;

            case "EthnicityId": dataValue = ethnicityId.ToString(); break;

            case "Ethnicity": dataValue = base.application.CoreObjectGetNameById("Ethnicity", ethnicityId); break;

            case "CitizenshipId": dataValue = citizenshipId.ToString(); break;

            case "Citizenship": dataValue = application.CoreObjectGetNameById("Citizenship", citizenshipId); break;

            case "LanguageId": dataValue = languageId.ToString(); break;

            case "Language": dataValue = application.CoreObjectGetNameById("Language", languageId); break;

            case "MaritalStatusId": dataValue = maritalStatusId.ToString(); break;

            case "MaritalStatus": dataValue = application.CoreObjectGetNameById("MaritalStatus", maritalStatusId); break;

            case "FamilyId": dataValue = FamilyId; break;


            case "Relationships":

                dataValue = "Relationships";

                foreach (MemberRelationship currentRelationship in base.application.MemberRelationshipsGet(Id))
                {
                    dataValue = dataValue + "|" + currentRelationship.Id;
                }

                break;


            case "Enrollments":

                dataValue = "Enrollment";

                foreach (MemberEnrollment currentEnrollment in base.application.MemberEnrollmentsGet(Id))
                {
                    dataValue = dataValue + "|" + currentEnrollment.Id;
                }

                break;


            case "CurrentEnrollment":

                if (HasCurrentEnrollment)
                {
                    bindingContextPart = bindingContext.Replace("CurrentEnrollment.", "");

                    dataValue = CurrentEnrollment.EvaluateDataBinding(bindingContextPart);
                }

                else
                {
                    dataValue = String.Empty;
                }

                break;

            case "CurrentEnrollmentCoverage":

                if (HasCurrentEnrollmentCoverage)
                {
                    bindingContextPart = bindingContextPart.Replace("CurrentEnrollmentCoverage.", "");

                    dataValue = CurrentEnrollmentCoverage.EvaluateDataBinding(bindingContextPart);
                }

                break;

            case "CurrentPcpAssignment":     // BACKWARDS COMPATIBILITY

            case "CurrentEnrollmentPcp":

                if (HasCurrentEnrollmentPcp)
                {
                    bindingContextPart = bindingContext.Replace("CurrentPcpAssignment.", "");      // BACKWARDS COMPATIBILITY

                    bindingContextPart = bindingContext.Replace("CurrentEnrollmentPcp.", "");

                    dataValue = CurrentEnrollmentPcp.EvaluateDataBinding(bindingContextPart);
                }

                else
                {
                    dataValue = String.Empty;
                }

                break;

            //case "PopulationMembership":

            //    dataValue = "PopulationMembership";

            //    List<Core.Population.PopulationMembership> populationMembership = application.PopulationMembershipGetByMember (memberId);

            //    foreach (Core.Population.PopulationMembership currentMembership in populationMembership) {

            //        dataValue = dataValue + "|" + currentMembership.Id.ToString ();

            //    }

            //    break;

            //case "MemberServices":

            //    dataValue = "MemberService";

            //    List<Int64> memberServices = application.MemberServiceGetIdListByMember (memberId);

            //    foreach (Int64 currentMemberServiceId in memberServices) {

            //        dataValue = dataValue + "|" + currentMemberServiceId.ToString ();

            //    }

            //    break;

            default: dataValue = base.EvaluateDataBinding(bindingContext); break;
            }

            return(dataValue);
        }