public async void Create_meta_throws_DbUpdateException_if_key_already_exists()
        {
            // Arrange
            var meta = new Meta {
                Key = "key", Value = "value"
            };
            var meta2 = new Meta {
                Key = "key", Value = "value"
            };

            // Act & Assert
            await _repo.CreateAsync(meta);

            var ex = await Assert.ThrowsAsync <DbUpdateException>(() => _repo.CreateAsync(meta2));
        }
示例#2
0
        public async void Meta_table_does_not_allow_duplicate_key_type_pair()
        {
            // Given 2 meta records with same Key and same Type
            var meta = new Meta {
                Key = "key", Value = "value", Type = EMetaType.Setting
            };
            var meta2 = new Meta {
                Key = "key", Value = "value", Type = EMetaType.Setting
            };

            // When inserting the 2nd record, FanException will throw
            await _repo.CreateAsync(meta);

            var ex = await Assert.ThrowsAsync <FanException>(() => _repo.CreateAsync(meta2));
        }