Example #1
0
        public void TaskSuccessTest()
        {
            var listPlatforms  = new ListPlatforms(DbContext);
            var allPlatforms   = listPlatforms.DoTask(null);
            var randomIndex    = new Random().Next(allPlatforms.Data.Count);
            var randomPlatform = allPlatforms.Data[randomIndex];

            Assert.IsNotNull(randomPlatform);

            var task   = new GetPlatform(DbContext);
            var result = task.DoTask(randomPlatform.Id);

            Assert.IsTrue(result.Success);
            Assert.IsNull(result.Exception);
            Assert.IsNotNull(result.Data);

            var platform = result.Data;

            Assert.AreEqual(randomPlatform.Name, platform.Name);
            Assert.AreEqual(randomPlatform.Website, platform.Website);
            Assert.IsNotNull(platform.Services);
            Assert.IsTrue(platform.Services.Any());
            foreach (var service in platform.Services)
            {
                Assert.IsTrue(randomPlatform.Services.Exists(s => s.Id == service.Id));
            }
        }
Example #2
0
        public void TaskSuccessTest()
        {
            var task         = new AddPlatform(DbContext);
            var testPlatform = TestsModel.Platform;
            var result       = task.DoTask(testPlatform);

            Assert.IsTrue(result.Success);
            Assert.IsNull(result.Exception);
            Assert.IsNotNull(result.Data);

            var platformId = result.Data;

            Assert.IsNotNull(platformId);
            Assert.IsTrue(platformId > 0);

            var getPlatformTask = new GetPlatform(DbContext);
            var platform        = getPlatformTask.DoTask(platformId.Value)?.Data;

            Assert.IsNotNull(platform);
            Assert.AreEqual(testPlatform.Name, platform.Name);
            Assert.AreEqual(testPlatform.Website, platform.Website);
            Assert.AreEqual(testPlatform.Services.Count, platform.Services.Count);
            foreach (var service in testPlatform.Services)
            {
                Assert.IsTrue(platform.Services.Exists(s => s.Id == service.Id));
            }

            var removePlatformTask = new RemovePlatform(DbContext);
            var removeResult       = removePlatformTask.DoTask(platform);

            Assert.IsTrue(removeResult.Success);
            Assert.IsNull(removeResult.Exception);
        }
Example #3
0
        public void TaskFailTest()
        {
            var task   = new GetPlatform(EmptyDbContext);
            var result = task.DoTask(0);

            Assert.IsFalse(result.Success);
            Assert.IsNotNull(result.Exception);
        }
Example #4
0
        public void TaskSuccessTest()
        {
            var listPlatformsTask = new ListPlatforms(DbContext);
            var allPlatforms      = listPlatformsTask.DoTask(null);
            var randomIndex       = new Random().Next(allPlatforms.Data.Count);
            var randomPlatform    = allPlatforms.Data[randomIndex];

            Assert.IsNotNull(randomPlatform);

            var oldPlatform = new Platform
            {
                Id       = randomPlatform.Id,
                Name     = randomPlatform.Name,
                Website  = randomPlatform.Website,
                Services = randomPlatform.Services
            };

            var task     = new UpdatePlatform(DbContext);
            var toUpdate = randomPlatform;

            UpdatePlatformModel(toUpdate);
            var result = task.DoTask(toUpdate);

            Assert.IsTrue(result.Success);
            Assert.IsNull(result.Exception);
            Assert.IsNull(result.Data);

            var getPlatformTask = new GetPlatform(DbContext);
            var platform        = getPlatformTask.DoTask(toUpdate.Id)?.Data;

            Assert.IsNotNull(platform);
            Assert.AreEqual(toUpdate.Name, platform.Name);
            Assert.AreEqual(toUpdate.Website, platform.Website);

            foreach (var service in toUpdate.Services)
            {
                var platformService = platform.PlatformServices.SingleOrDefault(ps => ps.ServiceId == service.Id);
                Assert.IsNotNull(platformService);
            }

            var revertPlatformResult = task.DoTask(oldPlatform);

            Assert.IsTrue(revertPlatformResult.Success);
            Assert.IsNull(revertPlatformResult.Exception);

            getPlatformTask = new GetPlatform(DbContext);
            platform        = getPlatformTask.DoTask(oldPlatform.Id)?.Data;

            Assert.IsNotNull(platform);
            Assert.AreEqual(oldPlatform.Name, platform.Name);
            Assert.AreEqual(oldPlatform.Website, platform.Website);
            Assert.AreEqual(oldPlatform.Services.Count, platform.PlatformServices.Count);
            foreach (var service in oldPlatform.Services)
            {
                var platformService = platform.PlatformServices.SingleOrDefault(ps => ps.ServiceId == service.Id);
                Assert.IsNotNull(platformService);
            }
        }
Example #5
0
        public void TheGamesDB_GetPlatformCall()
        {
            Dictionary <SearchParameters, object> searchParameters = new Dictionary <SearchParameters, object>()
            {
                { SearchParameters.id, 15 }
            };
            GetPlatform list = gamesDBList.MakeWebCall <GetPlatform>(searchParameters);

            Assert.AreNotEqual("", list.Platform);
        }
Example #6
0
        public void TheGamesDB_TestHTMLDecode()
        {
            GetPlatform retItem = gamesDBList.DeserializeOnly <GetPlatform>("<?xml version=\"1.0\" encoding=\"UTF-8\" ?><Data><baseImgUrl>http://thegamesdb.net/banners/</baseImgUrl><Platform><id>4946</id><Platform>Commodore 128</Platform><console>http://www.youtube.com/watch?v=4946.png</console><overview>The Commodore 128 is the last 8-bit home computer that was commercially released by Commodore Business Machines (CBM). Introduced in January 1985 at the CES in Las Vegas, it appeared three years after its predecessor, the bestselling Commodore 64. Some 64 software such as Bard&amp;#039;s Tale III and Kid Niki ran in 128 mode without stating this in the documentation, using the autoboot and the 1571&amp;#039;s faster disk access.  Some Infocom text adventures took advantage of the 80 column screen and increased memory capacity. Some C64 games were ported to native mode like Kikstart 2 and The Last V8 from Mastertronic, which have separate 128 versions, and Ultima V: Warriors of Destiny from Origin Systems, which uses extra RAM for music if running on the C128. The vast majority of games simply ran in 64 mode.</overview><developer>Commodore International</developer><manufacturer>Commodore Business Machines</manufacturer><cpu>Zilog Z80A @ 4 MHz</cpu><memory>128 kB</memory><graphics>VIC-II E (320×200, 16 colors, sprites, raster interrupt)</graphics><sound>SID 6581/8580 (3× Osc, 4× Wave, Filter, ADSR, Ring)</sound><maxcontrollers>2</maxcontrollers><Rating>10</Rating><Images><boxart side=\"back\" width=\"500\" height=\"750\">platform/boxart/4946-1.jpg</boxart><consoleart>platform/consoleart/4946.png</consoleart><controllerart>platform/controllerart/4946.png</controllerart></Images></Platform></Data>");

            Assert.IsTrue(retItem.Platform.Overview.Contains("Bard's Tale III"));
        }
Example #7
0
        public void TheGamesDB_GetPlatformDeserialize()
        {
            GetPlatform retItem = gamesDBList.DeserializeOnly <GetPlatform>(Properties.Resources.Interfaces_TheGamesDB_GetPlatform);

            Assert.AreNotEqual("", retItem.Platform);
        }