Exemplo n.º 1
0
        public void FindGigsByDateTest()
        {
            DateTime startDate; DateTime endDate; DateTime tempDate;
            int      numberOfGigs = 11;

            /* Generate gigs */
            startDate = DateTime.Now; tempDate = DateTime.Now;
            for (int i = 0; i < numberOfGigs; i++)
            {
                tempDate = tempDate.AddMonths(i);
                Gig gig = gigService.CreateGig(
                    Gig.CreateGig(-1, "gigNameTest" + i, tempDate, 1));
            }
            endDate = tempDate;

            /* It Checks that gigs have been successfully generated */
            List <Gig> gigs; int count = 10; int startIndex = 0;

            do
            {
                gigs = gigService.FindGigsByDate(
                    startDate, endDate, startIndex, count);
                Assert.That(gigs.Count <= count);
                startIndex += count;
            } while (gigs.Count == count);

            /* Check operations with incorrect/inverse date ranges */
            gigs = gigService.FindGigsByDate(
                endDate, startDate, startIndex, count);
            Assert.That(gigs.Count, Is.EqualTo(0));
        }
Exemplo n.º 2
0
        public void FindGigTest()
        {
            Gig expected = gigService.CreateGig(
                Gig.CreateGig(-1, "gigNameTest", DateTime.Now, 1));
            Gig actual = gigService.FindGig(expected.gigId);

            Assert.That(actual.gigId, Is.EqualTo(expected.gigId));
        }
Exemplo n.º 3
0
        public void CreateGigTest()
        {
            Gig actual = gigService.CreateGig(
                Gig.CreateGig(-1, "gigNameTest", DateTime.Now, 1));
            Gig expected = gigService.FindGig(actual.gigId);

            Assert.AreEqual(expected.gigId, actual.gigId);
        }
Exemplo n.º 4
0
        public void RemoveGigTest()
        {
            Boolean exceptionCatched = false;

            Gig gig = gigService.CreateGig(
                Gig.CreateGig(-1, "gigNameTest", DateTime.Now, 1));

            gigService.RemoveGig(gig.gigId);

            try
            {
                gigService.FindGig(gig.gigId);
            }
            catch (InstanceNotFoundException)
            {
                exceptionCatched = true;
            }

            Assert.That(exceptionCatched, Is.True);
        }
Exemplo n.º 5
0
        protected void BtnCreateClick(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                /* Create a Gig. */
                String nameGig = txtGigName.Text;

                DateTime gigDate = Convert.ToDateTime(txtCal.Text);

                byte musicTypeId = Byte.Parse(this.ddlGigType.SelectedItem.Value);
                Gig  gig         = Gig.CreateGig(-1, nameGig, gigDate, musicTypeId);


                Gig createdGig;

                #region Delegate on factories
                /* Create an "GigService". */
                //IGigService gigService = GigServiceFactory.GetService();


                #endregion

                #region Dependency Injection

                /* Get the Service */
                IUnityContainer container = (IUnityContainer)HttpContext.Current.Application["unityContainer"];
                gigService = container.Resolve <IGigService>();

                #endregion

                createdGig = gigService.CreateGig(gig);

                Context.Items.Add("createdGig", createdGig);

                LogManager.RecordMessage("Gig " + createdGig.gigId + " created.", MessageType.Info);

                Server.Transfer(Response.ApplyAppPathModifier("./GigCreated.aspx"));
            }
        }