public void GenerateDCACCurrentSource() { var generator = new CurrentSourceGenerator(); var parameters = new ParameterCollection { new ValueParameter("1"), // pin new ValueParameter("0"), // pin new WordParameter("Dc"), // dc new ValueParameter("1.2"), // dc-value new WordParameter("Ac"), // ac new ValueParameter("12"), // ac-magnitude new ValueParameter("0"), // ac-phase }; var context = Substitute.For <ICircuitContext>(); var entity = generator.Generate("i1", "i1", "i", parameters, context); Assert.NotNull(entity); Assert.IsType <CurrentSource>(entity); context.Received().SetParameter(entity, "dc", parameters[3], true); context.Received().SetParameter(entity, "acmag", parameters[5], true); context.Received().SetParameter(entity, "acphase", parameters[6], true); }
public void GenerateWaveformCurrentSource() { var sine = new Sine(); var generator = new CurrentSourceGenerator(); var parameters = new ParameterCollection { new ValueParameter("1"), // pin new ValueParameter("0"), // pin new BracketParameter() { Name = "sine", Parameters = new ParameterCollection() { new ValueParameter("0"), new ValueParameter("1"), new ValueParameter("2000"), }, }, }; var context = Substitute.For <ICircuitContext>(); context.WaveformReader.Supports("sine", context).Returns(true); context.WaveformReader.Generate(Arg.Any <string>(), Arg.Any <ParameterCollection>(), Arg.Any <ICircuitContext>()).Returns(sine); var entity = generator.Generate("i1", "i1", "i", parameters, context); Assert.NotNull(entity); Assert.IsType <CurrentSource>(entity); }
public void GenerateDCCurrentSourceWithoutCurrent() { var generator = new CurrentSourceGenerator(); var parameters = new ParameterCollection { new ValueParameter("1"), // pin new ValueParameter("0"), // pin new WordParameter("Dc"), // dc }; var context = Substitute.For <ICircuitContext>(); var entity = generator.Generate("i1", "i1", "i", parameters, context); Assert.NotNull(entity); Assert.IsType <CurrentSource>(entity); }
public void GenerateDCCurrentSourceWithoutDC() { var generator = new CurrentSourceGenerator(); var parameters = new ParameterCollection { new ValueParameter("1"), new ValueParameter("0"), new ValueParameter("1.2"), }; var context = Substitute.For <ICircuitContext>(); var entity = generator.Generate("i1", "i1", "i", parameters, context); Assert.NotNull(entity); Assert.IsType <CurrentSource>(entity); context.Received().SetParameter(entity, "dc", parameters[2], true); }
public void GeneratVCCS() { var generator = new CurrentSourceGenerator(); var parameters = new ParameterCollection { new ValueParameter("1"), // pin new ValueParameter("0"), // pin new ValueParameter("2"), // pin new ValueParameter("3"), // pin new ValueParameter("1.3"), // gain }; var context = Substitute.For <ICircuitContext>(); var entity = generator.Generate("g1", "g1", "g", parameters, context); Assert.NotNull(entity); Assert.IsType <VoltageControlledCurrentSource>(entity); context.Received().SetParameter(entity, "gain", parameters[4], true); }
public void GeneratCCCS() { var generator = new CurrentSourceGenerator(); var parameters = new ParameterCollection { new ValueParameter("1"), // pin new ValueParameter("0"), // pin new WordParameter("v1"), // controling source new ValueParameter("3"), // gain }; var context = Substitute.For <ICircuitContext>(); context.NameGenerator.GenerateObjectName(Arg.Any <string>()).Returns(x => x[0].ToString()); var entity = generator.Generate("f1", "f1", "f", parameters, context); Assert.NotNull(entity); Assert.IsType <CurrentControlledCurrentSource>(entity); Assert.Equal("v1", ((CurrentControlledCurrentSource)entity).ControllingName); context.Received().SetParameter(entity, "gain", parameters[3], true); }