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

            // Act
            string result = telescopeService.GetName(telescopeId);

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

            this.SeedDatabase(db);

            const int telescopeId = 1;

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

            // Act
            string actual = telescopeService.GetName(telescopeId);

            // Assert
            Assert.Equal(expected, actual);
        }