コード例 #1
0
        public void Edit_WithNotExistingName_ShouldEditTelescope()
        {
            // Arrange
            StarStuffDbContext db = this.Database;
            TelescopeService   telescopeService = new TelescopeService(db);

            this.SeedDatabase(db);

            const int telescopeId = 1;

            Telescope expected = new Telescope
            {
                Id             = telescopeId,
                Name           = "Test Name",
                Location       = "Test Location",
                Description    = "Test Description",
                MirrorDiameter = 55.62,
                ImageUrl       = "Test Image Url"
            };

            // Act
            telescopeService.Edit(
                telescopeId,
                expected.Name,
                expected.Location,
                expected.Description,
                expected.MirrorDiameter,
                expected.ImageUrl);

            Telescope actual = db.Telescopes.Find(telescopeId);

            // Assert
            this.CompareTelescopes(expected, actual);
        }
コード例 #2
0
        public void Edit_WithNotExistingId_ShouldReturnFalse()
        {
            // Arrange
            StarStuffDbContext db = this.Database;
            TelescopeService   telescopeService = new TelescopeService(db);

            const int telescopeId = 1;

            Telescope telescope = this.GetFakeTelescopes().FirstOrDefault(t => t.Id == telescopeId);

            // Act
            bool result = telescopeService.Edit(
                telescopeId,
                telescope.Name,
                telescope.Location,
                telescope.Description,
                telescope.MirrorDiameter,
                telescope.ImageUrl);

            // Assert
            Assert.False(result);
        }
コード例 #3
0
        public void Edit_WithSameName_ShouldEditTelescope()
        {
            // Arrange
            StarStuffDbContext db = this.Database;
            TelescopeService   telescopeService = new TelescopeService(db);

            this.SeedDatabase(db);

            const int telescopeId = 1;

            Telescope telescope = this.GetFakeTelescopes().FirstOrDefault(t => t.Id == telescopeId);

            // Act
            bool result = telescopeService.Edit(
                telescopeId,
                telescope.Name,
                "Test Location",
                "Test Description",
                56.88,
                "Test Image Url");

            // Assert
            Assert.True(result);
        }
コード例 #4
0
        public void Edit_WithSameName_ShouldReturnTrue()
        {
            // Arrange
            StarStuffDbContext db = this.Database;
            TelescopeService   telescopeService = new TelescopeService(db);

            this.SeedDatabase(db);

            const int telescopeId = 1;

            string telescopeName = this.GetFakeTelescopes().FirstOrDefault(t => t.Id == telescopeId).Name;

            Telescope expected = new Telescope
            {
                Id             = telescopeId,
                Name           = telescopeName,
                Location       = "Test Location",
                Description    = "Test Description",
                MirrorDiameter = 55.62,
                ImageUrl       = "Test Image Url"
            };

            // Act
            telescopeService.Edit(
                telescopeId,
                expected.Name,
                expected.Location,
                expected.Description,
                expected.MirrorDiameter,
                expected.ImageUrl);

            Telescope actual = db.Telescopes.Find(telescopeId);

            // Assert
            this.CompareTelescopes(expected, actual);
        }