public bool[] GetArrayWithoutThreeFirstAndThreeLastElements_GetArrayWithoutThreeFirstAndThreeLastElements(bool[] array) { // Act bool[] result = UsingRanges.GetArrayWithoutThreeFirstAndThreeLastElements(array); // Assert Assert.AreNotSame(array, result); return(result); }
public int[] GetArrayWithoutThreeLastElements_ReturnArrayWithoutThreeLastElements(int[] array) { // Act int[] result = UsingRanges.GetArrayWithoutThreeLastElements(array); // Assert Assert.AreNotSame(array, result); return(result); }
public void GetSerialNumberDetails(string serialNumber, string expectedCountryCode, string expectedManufacturerCode, string expectedFactoryCode, string expectedStationCode) { // Act UsingRanges.GetSerialNumberDetails(serialNumber, out string countryCode, out string manufacturerCode, out string factoryCode, out string stationCode); // Assert Assert.AreEqual(expectedCountryCode, countryCode); Assert.AreEqual(expectedManufacturerCode, manufacturerCode); Assert.AreEqual(expectedFactoryCode, factoryCode); Assert.AreEqual(expectedStationCode, stationCode); }
public void GetProductionCodeDetails_ParametersAreValid_ReturnsResult(string productionCode, string expectedRegionCode, string expectedLocationCode, string expectedDateCode, string expectedFactoryCode) { // Act UsingRanges.GetProductionCodeDetails(productionCode, out string regionCode, out string locationCode, out string dateCode, out string factoryCode); // Assert Assert.AreEqual(expectedRegionCode, regionCode); Assert.AreEqual(expectedLocationCode, locationCode); Assert.AreEqual(expectedDateCode, dateCode); Assert.AreEqual(expectedFactoryCode, factoryCode); }
protected override ILExpression VisitExpression(ILExpression expression) { if (expression.Code == ILCode.Stloc) { var variable = (ILVariable)expression.Operand; if (variable.Type.HasInterface("System.IDisposable")) { var key = Tuple.Create(variable, currentScope); if (starts.Keys.Any(k => k.Item1 == variable && k.Item2 != currentScope)) { LogTo.Warning("Method {0}: Using cannot be added because reassigning a variable in a condition is not supported.", method); } else { if (starts.ContainsKey(key)) { UsingRanges.Add(new ILRange { From = starts[key], To = expression.FirstILOffset() }); starts.Remove(key); } if (!currentTrys.Contains(expression.LastILOffset())) { starts.Add(key, expression.LastILOffset()); } } } } if (expression.Code == ILCode.Ret && currentScope > 1) { EarlyReturns.Add(expression.FirstILOffset()); } return(base.VisitExpression(expression)); }
protected override ILBlock VisitBlock(ILBlock block) { currentScope++; var result = base.VisitBlock(block); currentScope--; if (block.Body.Count == 0) { return(result); } var toOffset = block.LastILOffset(); if (toOffset < 0) { return(result); } foreach (var start in starts.Where(kvp => kvp.Key.Item2 == currentScope + 1).ToList()) { starts.Remove(start.Key); List <ILExpression> args; if (block.Body.Last().Match(ILCode.Ret, out args) && args.Count == 1 && args[0].MatchLdloc(start.Key.Item1)) { continue; // Returning the variable } UsingRanges.Add(new ILRange { From = start.Value, To = toOffset }); } return(result); }
public string GetStringWithoutThreeFirstAndThreeLastChars_StrIsValid_ReturnsResult(string str) { // Act return(UsingRanges.GetStringWithoutThreeFirstAndThreeLastChars(str)); }
public string GetStringWithoutLastChar_StrIsValid_ReturnsResult(string str) { // Act return(UsingRanges.GetStringWithoutLastChar(str)); }
public string GetStringWithAllChars_StrIsValid_ReturnsResult(string str) { // Act return(UsingRanges.GetStringWithAllChars(str)); }