This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Mock<IService> DefaultService() | |
{ | |
var mock = new Mock<IService>(); | |
mock.Setup(x => x.MyMethod(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>())) | |
.Returns<string, string, string>((typeName, comments, updatedBy) => Task.Run(() => | |
new MyType | |
{ | |
TypeName = typeName, | |
Comments = comments, | |
UpdatedBy = updatedBy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//ASYNC | |
[TestMethod] | |
public void GetTypesByName_WhenNoNameProvided_ThrowsArgumentException() | |
{ | |
//Arrange | |
var builder = new TypeServiceBuilder(); | |
var service = builder.Build(); | |
//Act | |
Func<Task> call = async () => await service.GetTypesByName(null); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare @tableName varchar(200) | |
declare @columnName varchar(200) | |
declare @nullable varchar(50) | |
declare @datatype varchar(50) | |
declare @maxlen int | |
declare @sType varchar(50) | |
declare @sProperty varchar(200) | |
DECLARE table_cursor CURSOR FOR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public override int SaveChanges() | |
{ | |
var changed = ChangeTracker.Entries() | |
.Where(e => e.State == EntityState.Modified || e.State == EntityState.Added); | |
foreach (var item in changed) | |
{ | |
if (item.Entity is IReadOnlyEntity) | |
{ | |
item.State = EntityState.Unchanged; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LocationServiceBuilder | |
{ | |
//create default behaviors | |
IHttpService _httpService = Mock.Create<IHttpService>(); | |
IFileService _fileService = Mock.CreateLike<IFileService>(fs => fs.ReadAllLines(Arg.AnyString) == new string[] { "key" }); | |
//pass in your own dependency if needed | |
public LocationServiceBuilder WithHttpService(IHttpService httpService) | |
{ | |
_httpService = httpService; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Newtonsoft.Json; | |
using Newtonsoft.Json.Serialization; | |
var formatters = GlobalConfiguration.Configuration.Formatters; | |
var jsonFormatter = formatters.JsonFormatter; | |
var settings = jsonFormatter.SerializerSettings; | |
settings.Formatting = Formatting.Indented; | |
settings.ContractResolver = new CamelCasePropertyNamesContractResolver(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH cte AS | |
(SELECT *, ROW_NUMBER() OVER (PARTITION BY col1, col2, col3, col4 ORDER BY (SELECT 0)) AS DuplicateRowNumber | |
FROM table | |
) | |
--SELECT * FROM cte WHERE DuplicateRowNumber > 1 | |
DELETE FROM cte WHERE DuplicateRowNumber > 1 |
NewerOlder