コード例 #1
0
        public void GetByUniqueKey_ShouldReturnNull_WhenWrongKey()
        {
            // Arrange
            var context = GetContext();
            var repo    = new SqlConstructionRepo(context);

            var specificationId = _constructions[0].Specification.Id;
            var name            = _constructions[0].Name;
            var paintworkCoeff  = _constructions[0].PaintworkCoeff;

            // Act
            var additionalWork1 = repo.GetByUniqueKey(999, name, paintworkCoeff);
            var additionalWork2 = repo.GetByUniqueKey(specificationId, "NotFound", paintworkCoeff);
            var additionalWork3 = repo.GetByUniqueKey(specificationId, name, -1);

            // Assert
            Assert.Null(additionalWork1);
            Assert.Null(additionalWork2);
            Assert.Null(additionalWork3);

            context.Database.EnsureDeleted();
            context.Dispose();
        }
コード例 #2
0
        public void GetByUniqueKey_ShouldReturnConstruction()
        {
            // Arrange
            var context = GetContext();
            var repo    = new SqlConstructionRepo(context);

            var specificationId = _constructions[0].Specification.Id;
            var name            = _constructions[0].Name;
            var paintworkCoeff  = _constructions[0].PaintworkCoeff;

            // Act
            var construction = repo.GetByUniqueKey(
                specificationId, name, paintworkCoeff);

            // Assert
            Assert.Equal(_constructions.SingleOrDefault(
                             v => v.Specification.Id == specificationId &&
                             v.Name == name && v.PaintworkCoeff == paintworkCoeff), construction);

            context.Database.EnsureDeleted();
            context.Dispose();
        }