This file contains hidden or 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
/* | |
Write a test or tests to validate that the correct FubarData is passed to IFubarDataService.Validate(...) | |
from the Fubar that is passed to ValidateFubar. | |
e.g. did the Fubar.Name match the FubarData.Name | |
-- note: imagine there was 15+ properties on both Fubar and FubarData that needed validating | |
*/ | |
This file contains hidden or 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 System; | |
using Microsoft.VisualStudio.TestTools.UnitTesting; | |
using Microsoft.Practices.ServiceLocation; | |
using Moq; | |
namespace ServiceLocatorMocking | |
{ | |
[TestClass] | |
public class UnitTest1 | |
{ |
This file contains hidden or 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 CardValidationConfiguration { | |
public CallValidateConfiguration CallValidateConfiguration { get; set; } | |
public int MonthsFromLastPaymentExpiryDateIsValid { get; set;} | |
} | |
public CardValidationService(CardValidationConfiguration config |
This file contains hidden or 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 CardValidationService : ICardValidationService | |
{ | |
private readonly CallValidationConfiguration _config; | |
private readonly ICallValidateDataService _callValidateDataService; | |
private readonly ILogger _logger = LoggerProvider.GetLogger<CardValidationService>(); | |
public CardValidationService(CallValidationConfiguration config, ICallValidateDataService callValidateDataService) | |
{ | |
_config = config; | |
_callValidateDataService = callValidateDataService; |
This file contains hidden or 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 bool ValidateExpiryDate(string cardExpiryDate, DateTime lastPaymentDate) | |
{ | |
if (cardExpiryDate == null || !CardDateUtil.FormatIsValid(cardExpiryDate)) return false; | |
DateTime expiryDate = CardDateUtil.ConvertToDateTime(cardExpiryDate, SetDayOfMonth.LastDayOfMonth); | |
var invalidExpiryDate = lastPaymentDate.AddMonths(3); //TODO: pass as variable | |
var inDate = expiryDate >= invalidExpiryDate; |
This file contains hidden or 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 CardValidationService : ICardValidationService | |
{ | |
private readonly CallValidationConfiguration _config; | |
private readonly ICallValidateDataService _callValidateDataService; | |
private readonly ILogger _logger = LoggerProvider.GetLogger<CardValidationService>(); | |
public CardValidationService(CallValidationConfiguration config, ICallValidateDataService callValidateDataService) | |
{ | |
_config = config; | |
_callValidateDataService = callValidateDataService; |
This file contains hidden or 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 JsonSerialiser : ISerialiser | |
{ | |
public string Serialize<T>(T t) | |
{ | |
var ser = new DataContractJsonSerializer(typeof(T)); | |
var ms = new MemoryStream(); | |
ser.WriteObject(ms, t); | |
string jsonString = Encoding.UTF8.GetString(ms.ToArray()); | |
ms.Close(); |
This file contains hidden or 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 InventoryController : ApiController | |
{ | |
private readonly IInventoryManagementService _inventoryManagementService; | |
private readonly IUnitOfWork _unitOfWork; | |
public InventoryController(IUnitOfWork unitOfWork) | |
{ | |
_unitOfWork = unitOfWork; //access services | |
_inventoryManagementService = _unitOfWork.Get<IInventoryManagementService>(); | |
} |
This file contains hidden or 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 ApplicationController : WorkflowController | |
{ | |
public ApplicationController(IWorkflowKeyStore workflowKeyStore, IWorkflowInvokerFactory workflowInvokerFactory) | |
: base("face2face", "Vanquis.NewBusiness.PL.Models", "Vanquis.NewBusiness.PL.Models", workflowKeyStore, workflowInvokerFactory) { } | |
[NoCache] | |
[Authorize] | |
public ActionResult Index() | |
{ | |
LogSystem.log.Debug("ApplicationController/Index"); |
This file contains hidden or 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 abstract class WorkflowController : BaseController | |
{ | |
private string _workflowReference; | |
private readonly string _modelNamespace; | |
private readonly string _modelAssembly; | |
private IWorkflowKeyStore _workflowKeyStore; | |
private IWorkflowInvokerFactory _invokerFactory; | |
protected WorkflowController(string workflowReference, string modelNamespace, string modelAssembly, IWorkflowKeyStore workflowKeyStore, IWorkflowInvokerFactory workflowInvokerFactory) | |
{ |