Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Need any help on your open-source project?

Magnus Markling memark

💭
Need any help on your open-source project?
  • Mandolin Consulting
  • Göteborg, Sweden
  • @memark
View GitHub Profile
@memark
memark / logging.py
Last active Sep 27, 2020
iso format timestamp python
View logging.py
import logging
logger = logging.getLogger()
ch = logging.StreamHandler()
formatter = logging.Formatter(fmt='%(asctime)s.%(msecs)03dZ - %(msg)s', datefmt='%Y-%m-%dT%H:%M:%S')
ch.setFormatter(formatter)
logger.addHandler(ch)
logger.warning("some message")
View RegisterBusinessLogicStubs_many_methods.cs
private static void RegisterBusinessLogicStubs(ContainerBuilder containerBuilder)
{
var tempContainer = CreateBusinessLogicAutofacModuleContainer();
var interfaceToStubList = GetInterfaceTypeList(tempContainer);
var stubList = interfaceToStubList.Select(x => Substitute.For(new[] { x }, new object[] { }));
foreach (var s in stubList)
containerBuilder.RegisterInstance(s).AsImplementedInterfaces();
}
View RegisterBusinessLogicStubs_one_method.cs
private static void RegisterBusinessLogicStubs(ContainerBuilder containerBuilder)
{
var tempContainerBuilder = new ContainerBuilder();
var module = BusinessLogicAutofacModule.CreateWithoutDatabaseDefaults(default, default, default, default, default, default, default, default);
containerBuilder.RegisterModule(module);
var tempContainer = tempContainerBuilder.Build();
var interfaceToStubList = tempContainer.ComponentRegistry.Registrations
.SelectMany(x => x.Services)
.OfType<IServiceWithType>()
View MockExtensions.cs
namespace Jwc.MoqExtensions
{
using Moq;
using System;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using Xunit;
public interface IFoo
You can’t perform that action at this time.